Patchwork [pph] Fix marking of in-memory streams (issue5544085)

login
register
mail settings
Submitter Diego Novillo
Date Jan. 17, 2012, 3:18 p.m.
Message ID <20120117151831.20853AE1D7@tobiano.tor.corp.google.com>
Download mbox | patch
Permalink /patch/136491/
State New
Headers show

Comments

Diego Novillo - Jan. 17, 2012, 3:18 p.m.
We were marking STREAM in-memory too late.  This was causing repeated
attempts to open the same PPH stream more than once.  Leading to
confusion.

	* pph-in.c (pph_read_file_1): Move in-memory marking for STREAM...
	* pph-core.c (pph_stream_register): ... here.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@183250 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/cp/ChangeLog.pph |    5 +++++
 gcc/cp/pph-core.c    |    4 ++++
 gcc/cp/pph-in.c      |    8 ++------
 3 files changed, 11 insertions(+), 6 deletions(-)

Patch

diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph
index 6d3debe..88bc68f 100644
--- a/gcc/cp/ChangeLog.pph
+++ b/gcc/cp/ChangeLog.pph
@@ -1,3 +1,8 @@ 
+2012-01-17   Diego Novillo  <dnovillo@google.com>
+
+	* pph-in.c (pph_read_file_1): Move in-memory marking for STREAM...
+	* pph-core.c (pph_stream_register): ... here.
+
 2012-01-16   Diego Novillo  <dnovillo@google.com>
 
 	* name-lookup.c (pph_set_global_identifier_bindings): Make
diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c
index 6d34bd0..9f7f063 100644
--- a/gcc/cp/pph-core.c
+++ b/gcc/cp/pph-core.c
@@ -953,6 +953,10 @@  pph_stream_register (pph_stream *stream)
 
   /* Add a mapping between STREAM's PPH file name and STREAM.  */
   pph_stream_registry_add_name (stream, stream->name);
+
+  /* Mark this file as being in memory.  This prevents opening the
+     same file more than twice.  */
+  stream->in_memory_p = true;
 }
 
 
diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c
index 6a8fbf8..e9a5563 100644
--- a/gcc/cp/pph-in.c
+++ b/gcc/cp/pph-in.c
@@ -2839,8 +2839,8 @@  pph_read_file_1 (pph_stream *stream)
   VEC(tree,gc) *file_unemitted_tinfo_decls;
   source_location cpp_token_replay_loc;
 
-  /* If we have read STREAM before, we do not need to re-read the rest
-     of its body.  We only needed to read its line table.  */
+  /* If we have opened STREAM before, we do not need to re-read the rest
+     of its body.  */
   if (stream->in_memory_p)
     return;
 
@@ -2890,10 +2890,6 @@  pph_read_file_1 (pph_stream *stream)
   /* Read and process the symbol table.  */
   pph_in_symtab (stream);
 
-  /* Mark this file as read.  If other images need to access its contents,
-     we will not need to actually read it again.  */
-  stream->in_memory_p = true;
-
   if (flag_pph_dump_tree)
     pph_dump_namespace (pph_logfile, global_namespace);
 }