aboutsummaryrefslogtreecommitdiff
path: root/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-11-11 23:20:51 +0000
committerSteve Naroff <snaroff@apple.com>2007-11-11 23:20:51 +0000
commitd6d054da8e0cfd320f2bba2f97ecdb1511b1cbc4 (patch)
treebb0a3968aa8dfe07d14d613fa6b1574296b0dce0 /Sema/SemaDecl.cpp
parent409be835b68344e0de56f99ef9a1e12760bc69ee (diff)
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44000 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Sema/SemaDecl.cpp')
-rw-r--r--Sema/SemaDecl.cpp45
1 files changed, 9 insertions, 36 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index e043fa19f6..c0fb92c420 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -996,47 +996,18 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
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 @@ void Sema::ActOnMethodDefBody(DeclTy *D, StmtTy *Body) {
}
}
LabelMap.clear();
+
+ return D;
}
/// ObjcActOnStartOfMethodDef - This routine sets up parameters; invisible