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
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index e043fa1..c0fb92c 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -996,11 +996,14 @@
   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");
+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);
+  }
   CurFunctionDecl = 0;
   
   // Verify and clean out per-function state.
@@ -1025,37 +1028,7 @@
   }
   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) {
-    // 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);
-    }
-  }
-  LabelMap.clear();
+  return D;
 }
 
 /// ObjcActOnStartOfMethodDef - This routine sets up parameters; invisible