]> granicus.if.org Git - clang/commitdiff
ASTConsumer::handleTopLevelDecl will end up getting called for
authorDouglas Gregor <dgregor@apple.com>
Mon, 7 Nov 2011 18:53:57 +0000 (18:53 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 7 Nov 2011 18:53:57 +0000 (18:53 +0000)
function template instantiations. Fixes <rdar://problem/10398005> / PR11312.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143984 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/ASTUnit.cpp
test/Index/reparse-instantiate.cpp [new file with mode: 0644]

index 8d2884f7507190476b4efec7e802dca18e4d0097..2496f72bea9b2921e21589de8cd80790d06ab416 100644 (file)
@@ -2480,7 +2480,10 @@ static inline bool compLocDecl(std::pair<unsigned, Decl *> L,
 
 void ASTUnit::addFileLevelDecl(Decl *D) {
   assert(D);
-  assert(!D->isFromASTFile() && "This is only for local decl");
+  
+  // We only care about local declarations.
+  if (D->isFromASTFile())
+    return;
 
   SourceManager &SM = *SourceMgr;
   SourceLocation Loc = D->getLocation();
diff --git a/test/Index/reparse-instantiate.cpp b/test/Index/reparse-instantiate.cpp
new file mode 100644 (file)
index 0000000..84e5860
--- /dev/null
@@ -0,0 +1,7 @@
+int main()
+{
+  return 0;
+}
+
+// RUN: c-index-test -write-pch %t.pch -fno-delayed-template-parsing -x c++-header %S/Inputs/reparse-instantiate.h
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -fno-delayed-template-parsing -I %S/Inputs -include %t %s