[cfe-commits] r117534 - in /cfe/trunk: include/clang/Serialization/ASTWriter.h lib/Serialization/ASTWriter.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Oct 28 00:38:45 PDT 2010


Author: akirtzidis
Date: Thu Oct 28 02:38:45 2010
New Revision: 117534

URL: http://llvm.org/viewvc/llvm-project?rev=117534&view=rev
Log:
Fix the re-serializing decls in a chained PCH mechanism.

Modified:
    cfe/trunk/include/clang/Serialization/ASTWriter.h
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=117534&r1=117533&r2=117534&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Oct 28 02:38:45 2010
@@ -448,6 +448,12 @@
     UpdatedNamespaces.insert(NS);
   }
 
+  void RewriteDecl(const Decl *D) {
+    DeclsToRewrite.insert(D);
+    // Reset the flag, so that we don't add this decl multiple times.
+    const_cast<Decl *>(D)->setChangedSinceDeserialization(false);
+  }
+
   /// \brief Note that the identifier II occurs at the given offset
   /// within the identifier table.
   void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset);

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=117534&r1=117533&r2=117534&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Oct 28 02:38:45 2010
@@ -2395,10 +2395,6 @@
     else
       WriteDecl(Context, DOT.getDecl());
   }
-  for (DeclsToRewriteTy::iterator
-         I = DeclsToRewrite.begin(), E = DeclsToRewrite.end(); I != E; ++I) {
-    WriteDecl(Context, const_cast<Decl*>(*I));
-  }
   Stream.ExitBlock();
 
   WritePreprocessor(PP);
@@ -2604,6 +2600,9 @@
 
   Stream.EnterSubblock(DECLTYPES_BLOCK_ID, 3);
   WriteDeclsBlockAbbrevs();
+  for (DeclsToRewriteTy::iterator
+         I = DeclsToRewrite.begin(), E = DeclsToRewrite.end(); I != E; ++I)
+    DeclTypesToEmit.push(const_cast<Decl*>(*I));
   while (!DeclTypesToEmit.empty()) {
     DeclOrType DOT = DeclTypesToEmit.front();
     DeclTypesToEmit.pop();
@@ -3287,7 +3286,7 @@
       // A forward reference was mutated into a definition. Rewrite it.
       // FIXME: This happens during template instantiation, should we
       // have created a new definition decl instead ?
-      DeclsToRewrite.insert(RD);
+      RewriteDecl(RD);
     }
 
     for (CXXRecordDecl::redecl_iterator





More information about the cfe-commits mailing list