r175860 - [libclang] Fix a crash with invalid code, while skip function bodies is enabled.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Feb 21 20:11:06 PST 2013
Author: akirtzidis
Date: Thu Feb 21 22:11:06 2013
New Revision: 175860
URL: http://llvm.org/viewvc/llvm-project?rev=175860&view=rev
Log:
[libclang] Fix a crash with invalid code, while skip function bodies is enabled.
Modified:
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Index/index-file.cpp
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=175860&r1=175859&r2=175860&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Thu Feb 21 22:11:06 2013
@@ -1974,7 +1974,7 @@ Decl *Parser::ParseFunctionStatementBody
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);
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=175860&r1=175859&r2=175860&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Feb 21 22:11:06 2013
@@ -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);
}
Modified: cfe/trunk/test/Index/index-file.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-file.cpp?rev=175860&r1=175859&r2=175860&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-file.cpp (original)
+++ cfe/trunk/test/Index/index-file.cpp Thu Feb 21 22:11:06 2013
@@ -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
More information about the cfe-commits
mailing list