[cfe-commits] r143984 - in /cfe/trunk: lib/Frontend/ASTUnit.cpp test/Index/reparse-instantiate.cpp

Douglas Gregor dgregor at apple.com
Mon Nov 7 10:53:58 PST 2011


Author: dgregor
Date: Mon Nov  7 12:53:57 2011
New Revision: 143984

URL: http://llvm.org/viewvc/llvm-project?rev=143984&view=rev
Log:
ASTConsumer::handleTopLevelDecl will end up getting called for
function template instantiations. Fixes <rdar://problem/10398005> / PR11312.

Added:
    cfe/trunk/test/Index/reparse-instantiate.cpp
Modified:
    cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=143984&r1=143983&r2=143984&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Nov  7 12:53:57 2011
@@ -2480,7 +2480,10 @@
 
 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();

Added: cfe/trunk/test/Index/reparse-instantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/reparse-instantiate.cpp?rev=143984&view=auto
==============================================================================
--- cfe/trunk/test/Index/reparse-instantiate.cpp (added)
+++ cfe/trunk/test/Index/reparse-instantiate.cpp Mon Nov  7 12:53:57 2011
@@ -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





More information about the cfe-commits mailing list