[cfe-commits] r54032 - in /cfe/trunk/lib: Parse/ParseObjc.cpp Sema/SemaDecl.cpp Sema/SemaDeclObjC.cpp
Steve Naroff
snaroff at apple.com
Fri Jul 25 10:57:26 PDT 2008
Author: snaroff
Date: Fri Jul 25 12:57:26 2008
New Revision: 54032
URL: http://llvm.org/viewvc/llvm-project?rev=54032&view=rev
Log:
Move fix in r54013 from the parser to sema.
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=54032&r1=54031&r2=54032&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Jul 25 12:57:26 2008
@@ -1292,10 +1292,8 @@
EnterScope(Scope::FnScope|Scope::DeclScope);
// Tell the actions module that we have entered a method definition with the
- // specified Declarator for the method. If we don't have an MDecl, avoid
- // calling the actions module.
- if (MDecl)
- Actions.ObjCActOnStartOfMethodDef(CurScope, MDecl);
+ // specified Declarator for the method.
+ Actions.ObjCActOnStartOfMethodDef(CurScope, MDecl);
StmtResult FnBody = ParseCompoundStatementBody();
@@ -1307,8 +1305,7 @@
ExitScope();
// TODO: Pass argument information.
- if (MDecl)
- Actions.ActOnFinishFunctionBody(MDecl, FnBody.Val);
+ Actions.ActOnFinishFunctionBody(MDecl, FnBody.Val);
return MDecl;
}
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=54032&r1=54031&r2=54032&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jul 25 12:57:26 2008
@@ -1576,12 +1576,13 @@
Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtTy *Body) {
Decl *dcl = static_cast<Decl *>(D);
- if (FunctionDecl *FD = dyn_cast<FunctionDecl>(dcl)) {
+ if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(dcl)) {
FD->setBody((Stmt*)Body);
assert(FD == getCurFunctionDecl() && "Function parsing confused");
- } else if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(dcl)) {
+ } else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
MD->setBody((Stmt*)Body);
- }
+ } else
+ return 0;
PopDeclContext();
// Verify and clean out per-function state.
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=54032&r1=54031&r2=54032&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jul 25 12:57:26 2008
@@ -22,8 +22,11 @@
/// and user declared, in the method definition's AST.
void Sema::ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
assert(getCurMethodDecl() == 0 && "Method parsing confused");
- ObjCMethodDecl *MDecl = dyn_cast<ObjCMethodDecl>(static_cast<Decl *>(D));
- assert(MDecl != 0 && "Not a method declarator!");
+ ObjCMethodDecl *MDecl = dyn_cast_or_null<ObjCMethodDecl>((Decl *)D);
+
+ // If we don't have a valid method decl, simply return.
+ if (!MDecl)
+ return;
// Allow the rest of sema to find private method decl implementations.
if (MDecl->isInstance())
More information about the cfe-commits
mailing list