From 61d63d0fd7b3ebe3dc5a4d09c8adfd2bf28e93d3 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 7 Nov 2011 18:53:57 +0000 Subject: [PATCH] ASTConsumer::handleTopLevelDecl will end up getting called for function template instantiations. Fixes / PR11312. llvm-svn: 143984 --- clang/lib/Frontend/ASTUnit.cpp | 5 ++++- clang/test/Index/reparse-instantiate.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 clang/test/Index/reparse-instantiate.cpp diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 8d2884f75071..2496f72bea9b 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -2480,7 +2480,10 @@ static inline bool compLocDecl(std::pair 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/clang/test/Index/reparse-instantiate.cpp b/clang/test/Index/reparse-instantiate.cpp new file mode 100644 index 000000000000..84e58605c48f --- /dev/null +++ b/clang/test/Index/reparse-instantiate.cpp @@ -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