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]

[pph] Add support for disabling PPH input (issue5593043)


This patch adds support for disabling PPH reads.  It uses the new
support to disable PPH reading when we disable PPH writing.  This is
to avoid confusion in the PPH registration code that will have some
stale content after the output file has been removed.

Lawrence suggests that we should just fail hard when we cannot
generate a PPH image.  We are currently only emitting a warning.  I
think I will just rip out this support in the near future.  For now,
it was easier to just disable the reader.  For now, I'm leaving it in
just in case we have another need for this.


2012-01-27   Diego Novillo  <dnovillo@google.com>

c-family/ChangeLog.pph
	* c-common.h (pph_disable_reader): Declare.
	* c-opts.c (pph_disable_reader): New.

cp/ChangeLog.pph
	* pph-core.c (pph_include_handler): If PPH has been disabled,
	process the file as a regular text include.
	* pph-out.c (pph_disable_output): Also disable the reader.

diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index f8813c1..315e99e 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -590,6 +590,11 @@ extern const char *pph_out_file;
 extern bool
 pph_reader_enabled_p (void);
 
+/* Disable the PPH reader.  */
+
+extern void
+pph_disable_reader (void);
+
 /* Query for a mapping from an INCLUDE to a PPH file.
    Return the filename, without ownership.
    If there is no mapping, return null.  */
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 0ad27e2..ab71678 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -140,6 +140,18 @@ pph_reader_enabled_p (void)
   return include_pph_mapping != NULL;
 }
 
+
+/* Disable PPH reading.  After this function is called, all subsequent
+   #include commands will be processed as textual includes.  */
+
+void
+pph_disable_reader (void)
+{
+  strstrmap_destroy (include_pph_mapping);
+  include_pph_mapping = NULL;
+}
+
+
 /* Add mappings from include directive to PPH files found within file FILENAME.
    The file is a sequence of lines.
    Each line contains the directive, followed by a tab,
diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c
index 5f6c27f..760d065 100644
--- a/gcc/cp/pph-core.c
+++ b/gcc/cp/pph-core.c
@@ -784,6 +784,11 @@ pph_include_handler (cpp_reader *reader,
       fprintf (pph_logfile, "%c\n", angle_brackets ? '>' : '"');
     }
 
+  /* If PPH has been disabled, process the #include as a regular
+     text include.  */
+  if (!pph_enabled_p ())
+    return true;
+
   /* If we find a #include_next directive in the primary file,
      refuse to generate a PPH image for it.  #include_next cannot
      be resolved from the primary source file, so generating an
diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c
index 31620e3..a1ce886 100644
--- a/gcc/cp/pph-out.c
+++ b/gcc/cp/pph-out.c
@@ -2854,6 +2854,11 @@ pph_disable_output (void)
   pph_stream_close_no_flush (pph_out_stream);
   pph_out_file = NULL;
   pph_out_stream = NULL;
+
+  /* Also disable the reader.  We are not generating a PPH image anymore,
+     so it makes no sense to keep reading images.  FIXME pph, instead
+     of disabling PPH generation we may want to simply abort compilation.  */
+  pph_disable_reader ();
 }
 
 #include "gt-cp-pph-out.h"

--
This patch is available for review at http://codereview.appspot.com/5593043


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