This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cppfiles.c follow-up


Neil Booth wrote:-

> Andrew Pinski wrote:-
> 
> > Now gcc does not produce full paths when using -MT -MD.
> 
> Thanks, I'll look into it.

I expect this patch fixes it.  I cannot test it as I cannot bootstrap
(it fails at end of stage2 for clean checkou).  It also fixes other minor
issues I noticed.

This patch is mostly comment fixes.  If I can't bootstrap in the next
hour or so, I'll apply it as obvious.

Neil.

	* Makefile.in: Refine dependencies.
	* c-opts.c (c_common_handle_option): Do nothing for -Wimport.
	* c.opt: Update help for -Wimport.
	* cppfiles.c: Include hashtab.h.  Update comments.
	(stack_file, open_file_failed): Use full path for dependency output.
	(once_only_file_p): Be smarter about marking once-only files.
	(_cpp_mark_file_once_only): Correct the check for existence on
	the list.
	* cpphash.h: Don't include hashtab.h.
	(struct _cpp_file): Remove.
	(struct cpp_reader): Update.
	* cppinit.c (cpp_create_reader): Don't initialize warn_import.
	* cpplib.h (struct cpp_options): Remove warn_import.
	(cpp_simplify_path): Remove.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1130
diff -u -p -r1.1130 Makefile.in
--- Makefile.in	29 Jul 2003 23:36:46 -0000	1.1130
+++ Makefile.in	30 Jul 2003 21:18:33 -0000
@@ -2348,7 +2348,7 @@ LIBCPP_OBJS =	cpplib.o cpplex.o cppmacro
 		hashtable.o line-map.o mkdeps.o cpppch.o
 
 LIBCPP_DEPS =	$(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \
-		$(HASHTAB_H) $(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H)
+		$(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H)
 
 # Most of the other archives built/used by this makefile are for
 # targets.  This one is strictly for the host.
@@ -2365,7 +2365,7 @@ cppmacro.o: cppmacro.c $(LIBCPP_DEPS)
 cpplib.o:   cpplib.c   $(LIBCPP_DEPS)
 cpphash.o:  cpphash.c  $(LIBCPP_DEPS)
 cpptrad.o:  cpptrad.c  $(LIBCPP_DEPS)
-cppfiles.o: cppfiles.c $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h
+cppfiles.o: cppfiles.c $(LIBCPP_DEPS) $(HASHTAB_H) mkdeps.h
 cppinit.o:  cppinit.c  $(LIBCPP_DEPS) mkdeps.h
 cpppch.o:   cpppch.c   $(LIBCPP_DEPS) mkdeps.h
 
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.82
diff -u -p -r1.82 c-opts.c
--- c-opts.c	30 Jul 2003 17:27:05 -0000	1.82
+++ c-opts.c	30 Jul 2003 21:18:33 -0000
@@ -486,7 +486,7 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_Wimport:
-      cpp_opts->warn_import = value;
+      /* Silently ignore for now.  */
       break;
 
     case OPT_Winvalid_offsetof:
Index: c.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c.opt,v
retrieving revision 1.12
diff -u -p -r1.12 c.opt
--- c.opt	28 Jul 2003 20:03:25 -0000	1.12
+++ c.opt	30 Jul 2003 21:18:34 -0000
@@ -251,7 +251,7 @@ Warn when a declaration does not specify
 
 Wimport
 C ObjC C++ ObjC++
-Warn about uses of the \"#import\" directive
+Deprecated.  This switch has no effect.
 
 Winvalid-offsetof
 C++ ObjC++
Index: cppfiles.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
retrieving revision 1.179
diff -u -p -r1.179 cppfiles.c
--- cppfiles.c	30 Jul 2003 06:43:33 -0000	1.179
+++ cppfiles.c	30 Jul 2003 21:18:34 -0000
@@ -27,6 +27,7 @@ Foundation, 59 Temple Place - Suite 330,
 #include "cpphash.h"
 #include "intl.h"
 #include "mkdeps.h"
+#include "hashtab.h"
 #include <dirent.h>
 
 /* Variable length record files on VMS will have a stat size that includes
@@ -68,8 +69,8 @@ struct _cpp_file
   /* The full path of the pch file.  */
   const char *pchname;
 
-  /* The file's path with the basename stripped, malloced.  NULL if it
-     hasn't been calculated yet.  */
+  /* The file's path with the basename stripped.  NULL if it hasn't
+     been calculated yet.  */
   const char *dir_name;
 
   /* Chain through #import-ed files or those  containing #pragma once.  */
@@ -83,8 +84,7 @@ struct _cpp_file
 
   /* The directory in the search path where FILE was found.  Used for
      #include_next and determining whether a header is a system
-     header.  Is NULL if the file was given as an absolute path, or
-     opened with read_file.  */
+     header.  */
   cpp_dir *dir;
 
   /* As filled in by stat(2) for the file.  */
@@ -126,23 +126,28 @@ struct _cpp_file
    its head pointed to by a slot in FILE_HASH.  The file name is what
    appeared between the quotes in a #include directive; it can be
    determined implicity from the hash table location or explicitly
-   from FILE->fname.
+   from FILE->name.
 
    FILE is a structure containing details about the file that was
    found with that search, or details of how the search failed.
 
    START_DIR is the starting location of the search in the include
    chain.  The current directories for "" includes are also hashed in
-   the hash table.  Files that are looked up without using a search
-   path, such as absolute filenames and file names from the command
-   line share a special starting directory so they don't get confused
-   with normal include-chain lookups in the cache.
+   the hash table and therefore unique.  Files that are looked up
+   without using a search path, such as absolute filenames and file
+   names from the command line share a special starting directory so
+   they don't cause cache hits with normal include-chain lookups.
 
    If START_DIR is NULL then the entry is for a directory, not a file,
    and the directory is in DIR.  Since the starting point in a file
    lookup chain is never NULL, this means that simple pointer
    comparisons against START_DIR can be made to determine cache hits
    in file lookups.
+
+   If a cache lookup fails because of e.g. an extra "./" in the path,
+   then nothing will break.  It is just less efficient as CPP will
+   have to do more work re-preprocessing the file, and/or comparing
+   its contents against earlier once-only files.
 */
 struct file_hash_entry
 {
@@ -537,7 +542,7 @@ stack_file (cpp_reader *pfile, _cpp_file
   if (CPP_OPTION (pfile, deps.style) > !!sysp && !file->stack_count)
     {
       if (!file->main_file || !CPP_OPTION (pfile, deps.ignore_main_file))
-	deps_add_dep (pfile->deps, file->name);
+	deps_add_dep (pfile->deps, file->path);
     }
 
   if (!read_file (pfile, file))
@@ -580,15 +585,12 @@ once_only_file_p (cpp_reader *pfile, _cp
     return true;
 
   /* Are we #import-ing a previously #import-ed file?  */
-  if (import)
-    {
-      if (file->import)
-	return true;
-      _cpp_mark_file_once_only (pfile, file, true);
-    }
+  if (import && file->import)
+    return true;
 
   /* Read the file contents now.  stack_file would do it later, and
-     we're smart enough to not do it twice, so this is no loss.  */
+     we're smart enough to not do it twice, so this is no loss.  Note
+     we don't mark the file once-only if we can't read it.  */
   if (!read_file (pfile, file))
     return false;
 
@@ -609,10 +611,13 @@ once_only_file_p (cpp_reader *pfile, _cp
 	  /* Size might have changed in read_file().  */
 	  && f->st.st_size == file->st.st_size
 	  && !memcmp (f->buffer, file->buffer, f->st.st_size))
-	return true;
+	break;
     }
 
-  return false;
+  if (import || f != NULL)
+    _cpp_mark_file_once_only (pfile, file, import);
+
+  return f != NULL;
 }
 
 /* Mark FILE to be included once only.  IMPORT is true if because of
@@ -620,22 +625,22 @@ once_only_file_p (cpp_reader *pfile, _cp
 void
 _cpp_mark_file_once_only (cpp_reader *pfile, _cpp_file *file, bool import)
 {
-  if (import)
-    file->import = true;
-  else
-    {
-      pfile->saw_pragma_once = true;
-      file->pragma_once = true;
-    }
-
   /* Put it on the once-only list if it's not on there already (an
      earlier #include with a #pragma once might have put it on there
      already).  */
-  if (file->once_only_next == NULL)
+  if (!file->import && !file->pragma_once)
     {
       file->once_only_next = pfile->once_only_files;
       pfile->once_only_files = file;
     }
+
+  if (import)
+    file->import = true;
+  else
+    {
+      pfile->saw_pragma_once = true;
+      file->pragma_once = true;
+    }
 }
 
 /* Return the directory from which searching for FNAME should start,
@@ -731,7 +736,7 @@ open_file_failed (cpp_reader *pfile, _cp
 
   errno = file->err_no;
   if (print_dep && CPP_OPTION (pfile, deps.missing_files) && errno == ENOENT)
-    deps_add_dep (pfile->deps, file->name);
+    deps_add_dep (pfile->deps, file->path);
   else
     {
       /* If we are outputting dependencies but not for this file then
Index: cpphash.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpphash.h,v
retrieving revision 1.195
diff -u -p -r1.195 cpphash.h
--- cpphash.h	29 Jul 2003 22:26:09 -0000	1.195
+++ cpphash.h	30 Jul 2003 21:18:34 -0000
@@ -24,7 +24,6 @@ Foundation, 59 Temple Place - Suite 330,
 #define GCC_CPPHASH_H
 
 #include "hashtable.h"
-#include "hashtab.h"
 
 #ifdef HAVE_ICONV
 #include <iconv.h>
@@ -37,7 +36,6 @@ struct directive;		/* Deliberately incom
 struct pending_option;
 struct op;
 struct strbuf;
-struct _cpp_file;
 
 typedef bool (*convert_f) (iconv_t, const unsigned char *, size_t,
 			   struct strbuf *);
@@ -365,7 +363,7 @@ struct cpp_reader
   struct _cpp_file *once_only_files;
 
   /* File and directory hash table.  */
-  htab_t file_hash;
+  struct htab *file_hash;
   struct file_hash_entry *file_hash_entries;
   unsigned int file_hash_entries_allocated, file_hash_entries_used;
 
Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.290
diff -u -p -r1.290 cppinit.c
--- cppinit.c	29 Jul 2003 22:26:10 -0000	1.290
+++ cppinit.c	30 Jul 2003 21:18:34 -0000
@@ -133,7 +133,6 @@ cpp_create_reader (enum c_lang lang, has
   pfile = xcalloc (1, sizeof (cpp_reader));
 
   cpp_set_lang (pfile, lang);
-  CPP_OPTION (pfile, warn_import) = 1;
   CPP_OPTION (pfile, warn_multichar) = 1;
   CPP_OPTION (pfile, discard_comments) = 1;
   CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1;
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.262
diff -u -p -r1.262 cpplib.h
--- cpplib.h	29 Jul 2003 22:26:11 -0000	1.262
+++ cpplib.h	30 Jul 2003 21:18:35 -0000
@@ -267,9 +267,6 @@ struct cpp_options
   /* Nonzero means warn if there are any trigraphs.  */
   unsigned char warn_trigraphs;
 
-  /* Nonzero means warn if #import is used.  */
-  unsigned char warn_import;
-
   /* Nonzero means warn about multicharacter charconsts.  */
   unsigned char warn_multichar;
 
@@ -712,7 +709,6 @@ extern unsigned char *cpp_quote_string (
 /* In cppfiles.c */
 extern bool cpp_included (cpp_reader *, const char *);
 extern void cpp_make_system_header (cpp_reader *, int, int);
-extern void cpp_simplify_path (char *);
 extern bool cpp_push_include (cpp_reader *, const char *);
 extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]