]> granicus.if.org Git - clang/commitdiff
Store the full list of pending instantiations in a chained PCH. Previously we attempt...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Sun, 24 Apr 2011 16:27:30 +0000 (16:27 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Sun, 24 Apr 2011 16:27:30 +0000 (16:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130098 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
test/PCH/chain-pending-instantiations.cpp [new file with mode: 0644]

index 3525c7020782a755a228ed0dcb3177a517d4975e..addd73ba356669a0d12c9c292340c94208ef27e6 100644 (file)
@@ -4118,22 +4118,22 @@ void ASTReader::InitializeSema(Sema &S) {
         SemaObj->ReferencedSelectors.insert(std::make_pair(Sel, SelLoc));
       }
     }
-
-    // If there were any pending implicit instantiations, deserialize them
-    // and add them to Sema's queue of such instantiations.
-    assert(F->PendingInstantiations.size() % 2 == 0 &&
-           "Expected pairs of entries");
-    for (unsigned Idx = 0, N = F->PendingInstantiations.size(); Idx < N;) {
-      ValueDecl *D=cast<ValueDecl>(GetDecl(F->PendingInstantiations[Idx++]));
-      SourceLocation Loc = ReadSourceLocation(*F, F->PendingInstantiations,Idx);
-      SemaObj->PendingInstantiations.push_back(std::make_pair(D, Loc));
-    }
   }
 
-  // The two special data sets below always come from the most recent PCH,
+  // The special data sets below always come from the most recent PCH,
   // which is at the front of the chain.
   PerFileData &F = *Chain.front();
 
+  // If there were any pending implicit instantiations, deserialize them
+  // and add them to Sema's queue of such instantiations.
+  assert(F.PendingInstantiations.size() % 2 == 0 &&
+         "Expected pairs of entries");
+  for (unsigned Idx = 0, N = F.PendingInstantiations.size(); Idx < N;) {
+    ValueDecl *D=cast<ValueDecl>(GetDecl(F.PendingInstantiations[Idx++]));
+    SourceLocation Loc = ReadSourceLocation(F, F.PendingInstantiations,Idx);
+    SemaObj->PendingInstantiations.push_back(std::make_pair(D, Loc));
+  }
+
   // If there were any weak undeclared identifiers, deserialize them and add to
   // Sema's list of weak undeclared identifiers.
   if (!WeakUndeclaredIdentifiers.empty()) {
index 7196a7271831b53f4f947e1dd61f2d5f228ceca5..fb193651b8769b0f31422cb28c343be0990f38ab 100644 (file)
@@ -3039,10 +3039,8 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
   for (std::deque<Sema::PendingImplicitInstantiation>::iterator
          I = SemaRef.PendingInstantiations.begin(),
          N = SemaRef.PendingInstantiations.end(); I != N; ++I) {
-    if (I->first->getPCHLevel() == 0) {
-      AddDeclRef(I->first, PendingInstantiations);
-      AddSourceLocation(I->second, PendingInstantiations);
-    }
+    AddDeclRef(I->first, PendingInstantiations);
+    AddSourceLocation(I->second, PendingInstantiations);
   }
   assert(SemaRef.PendingLocalImplicitInstantiations.empty() &&
          "There are local ones at end of translation unit!");
diff --git a/test/PCH/chain-pending-instantiations.cpp b/test/PCH/chain-pending-instantiations.cpp
new file mode 100644 (file)
index 0000000..e49abcd
--- /dev/null
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -chain-include %s -chain-include %s | FileCheck %s
+// CHECK: define linkonce_odr %{{[^ ]+}} @_ZN1AI1BE3getEv
+#if !defined(PASS1)
+#define PASS1
+
+template <typename Derived>
+struct A {
+  Derived* get() { return 0; }
+};
+
+struct B : A<B> {
+};
+
+#elif !defined(PASS2)
+#define PASS2
+
+struct C : B {
+};
+
+struct D : C {
+  void run() {
+    (void)get();
+  }
+};
+
+#else
+
+int main() {
+  D d;
+  d.run();
+}
+
+#endif