[cfe-commits] r44000 - in /cfe/trunk: Parse/ParseObjc.cpp Parse/ParseStmt.cpp Sema/Sema.h Sema/SemaDecl.cpp include/clang/Parse/Action.h
Steve Naroff
snaroff at apple.com
Sun Nov 11 15:20:52 PST 2007
Author: snaroff
Date: Sun Nov 11 17:20:51 2007
New Revision: 44000
URL: http://llvm.org/viewvc/llvm-project?rev=44000&view=rev
Log:
Replace 2 method definition actions (ActOnFunctionDefBody, ActOnMethodDefBody) with 1 method definition action (ActOnFinishFunctionBody). I can't think of any reason that we would need two action hooks.
Modified:
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/Parse/ParseStmt.cpp
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=44000&r1=43999&r2=44000&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Sun Nov 11 17:20:51 2007
@@ -1175,7 +1175,7 @@
ExitScope();
// TODO: Pass argument information.
- Actions.ActOnMethodDefBody(MDecl, FnBody.Val);
+ Actions.ActOnFinishFunctionBody(MDecl, FnBody.Val);
}
Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
Modified: cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=44000&r1=43999&r2=44000&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/Parse/ParseStmt.cpp Sun Nov 11 17:20:51 2007
@@ -1046,5 +1046,5 @@
ExitScope();
// TODO: Pass argument information.
- return Actions.ActOnFunctionDefBody(Decl, FnBody.Val);
+ return Actions.ActOnFinishFunctionBody(Decl, FnBody.Val);
}
\ No newline at end of file
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=44000&r1=43999&r2=44000&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Sun Nov 11 17:20:51 2007
@@ -191,8 +191,8 @@
virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, Declarator &D);
virtual void ObjcActOnStartOfMethodDef(Scope *S, DeclTy *D);
- virtual DeclTy *ActOnFunctionDefBody(DeclTy *Decl, StmtTy *Body);
- virtual void ActOnMethodDefBody(DeclTy *Decl, StmtTy *Body);
+
+ virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtTy *Body);
/// Scope actions.
virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=44000&r1=43999&r2=44000&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sun Nov 11 17:20:51 2007
@@ -996,47 +996,18 @@
return FD;
}
-Sema::DeclTy *Sema::ActOnFunctionDefBody(DeclTy *D, StmtTy *Body) {
- FunctionDecl *FD = static_cast<FunctionDecl*>(D);
- FD->setBody((Stmt*)Body);
-
- assert(FD == CurFunctionDecl && "Function parsing confused");
- CurFunctionDecl = 0;
-
- // Verify and clean out per-function state.
-
- // Check goto/label use.
- for (llvm::DenseMap<IdentifierInfo*, LabelStmt*>::iterator
- I = LabelMap.begin(), E = LabelMap.end(); I != E; ++I) {
- // Verify that we have no forward references left. If so, there was a goto
- // or address of a label taken, but no definition of it. Label fwd
- // definitions are indicated with a null substmt.
- if (I->second->getSubStmt() == 0) {
- LabelStmt *L = I->second;
- // Emit error.
- Diag(L->getIdentLoc(), diag::err_undeclared_label_use, L->getName());
-
- // At this point, we have gotos that use the bogus label. Stitch it into
- // the function body so that they aren't leaked and that the AST is well
- // formed.
- L->setSubStmt(new NullStmt(L->getIdentLoc()));
- cast<CompoundStmt>((Stmt*)Body)->push_back(L);
- }
+Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtTy *Body) {
+ Decl *dcl = static_cast<Decl *>(D);
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(dcl)) {
+ FD->setBody((Stmt*)Body);
+ assert(FD == CurFunctionDecl && "Function parsing confused");
+ } else if (ObjcMethodDecl *MD = dyn_cast<ObjcMethodDecl>(dcl)) {
+ MD->setBody((Stmt*)Body);
}
- LabelMap.clear();
-
- return FD;
-}
-
-void Sema::ActOnMethodDefBody(DeclTy *D, StmtTy *Body) {
- ObjcMethodDecl *FD = static_cast<ObjcMethodDecl*>(D);
- FD->setBody((Stmt*)Body);
CurFunctionDecl = 0;
// Verify and clean out per-function state.
- // TODO: This code block is common with ActOnFunctionDefBody and need be
- // refactored.
// Check goto/label use.
for (llvm::DenseMap<IdentifierInfo*, LabelStmt*>::iterator
I = LabelMap.begin(), E = LabelMap.end(); I != E; ++I) {
@@ -1056,6 +1027,8 @@
}
}
LabelMap.clear();
+
+ return D;
}
/// ObjcActOnStartOfMethodDef - This routine sets up parameters; invisible
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=44000&r1=43999&r2=44000&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Sun Nov 11 17:20:51 2007
@@ -141,14 +141,10 @@
/// ActOnFunctionDefBody - This is called when a function body has completed
/// parsing. Decl is the DeclTy returned by ParseStartOfFunctionDef.
- virtual DeclTy *ActOnFunctionDefBody(DeclTy *Decl, StmtTy *Body) {
+ virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtTy *Body) {
return Decl;
}
- virtual void ActOnMethodDefBody(DeclTy *Decl, StmtTy *Body) {
- return;
- }
-
/// ActOnPopScope - This callback is called immediately before the specified
/// scope is popped and deleted.
virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {}
More information about the cfe-commits
mailing list