diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index a77c03459fa4..71a7b2c9f9ba 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1974,7 +1974,7 @@ Decl *Parser::ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope) { assert(Tok.is(tok::l_brace)); SourceLocation LBraceLoc = Tok.getLocation(); - if (SkipFunctionBodies && Actions.canSkipFunctionBody(Decl) && + if (SkipFunctionBodies && (!Decl || Actions.canSkipFunctionBody(Decl)) && trySkippingFunctionBody()) { BodyScope.Exit(); return Actions.ActOnSkippedFunctionBody(Decl); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 189b3d94e2bc..03d18d402d5f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -8449,9 +8449,9 @@ bool Sema::canSkipFunctionBody(Decl *D) { } Decl *Sema::ActOnSkippedFunctionBody(Decl *Decl) { - if (FunctionDecl *FD = dyn_cast(Decl)) + if (FunctionDecl *FD = dyn_cast_or_null(Decl)) FD->setHasSkippedBody(); - else if (ObjCMethodDecl *MD = dyn_cast(Decl)) + else if (ObjCMethodDecl *MD = dyn_cast_or_null(Decl)) MD->setHasSkippedBody(); return ActOnFinishFunctionBody(Decl, 0); } diff --git a/clang/test/Index/index-file.cpp b/clang/test/Index/index-file.cpp index bf2d62c55680..7634c0db863f 100644 --- a/clang/test/Index/index-file.cpp +++ b/clang/test/Index/index-file.cpp @@ -1,5 +1,9 @@ using MyTypeAlias = int; +extern "C" { + template < typename T > *Allocate() { } +} + // RUN: c-index-test -index-file %s > %t // RUN: FileCheck %s -input-file=%t