forked from OSchip/llvm-project
[libclang] Fix a crash with invalid code, while skip function bodies is enabled.
llvm-svn: 175860
This commit is contained in:
parent
62eae089ca
commit
4431918f40
|
@ -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);
|
||||
|
|
|
@ -8449,9 +8449,9 @@ bool Sema::canSkipFunctionBody(Decl *D) {
|
|||
}
|
||||
|
||||
Decl *Sema::ActOnSkippedFunctionBody(Decl *Decl) {
|
||||
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(Decl))
|
||||
if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Decl))
|
||||
FD->setHasSkippedBody();
|
||||
else if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(Decl))
|
||||
else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(Decl))
|
||||
MD->setHasSkippedBody();
|
||||
return ActOnFinishFunctionBody(Decl, 0);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue