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.
llvm-svn: 44000
This commit is contained in:
parent
bb87572d70
commit
b313fc3203
|
|
@ -1175,7 +1175,7 @@ void Parser::ParseObjCMethodDefinition() {
|
||||||
ExitScope();
|
ExitScope();
|
||||||
|
|
||||||
// TODO: Pass argument information.
|
// TODO: Pass argument information.
|
||||||
Actions.ActOnMethodDefBody(MDecl, FnBody.Val);
|
Actions.ActOnFinishFunctionBody(MDecl, FnBody.Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
|
Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
|
||||||
|
|
|
||||||
|
|
@ -1046,5 +1046,5 @@ Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl,
|
||||||
ExitScope();
|
ExitScope();
|
||||||
|
|
||||||
// TODO: Pass argument information.
|
// TODO: Pass argument information.
|
||||||
return Actions.ActOnFunctionDefBody(Decl, FnBody.Val);
|
return Actions.ActOnFinishFunctionBody(Decl, FnBody.Val);
|
||||||
}
|
}
|
||||||
|
|
@ -191,8 +191,8 @@ private:
|
||||||
|
|
||||||
virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, Declarator &D);
|
virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, Declarator &D);
|
||||||
virtual void ObjcActOnStartOfMethodDef(Scope *S, DeclTy *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.
|
/// Scope actions.
|
||||||
virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
|
virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
|
||||||
|
|
|
||||||
|
|
@ -996,11 +996,14 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
|
||||||
return FD;
|
return FD;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sema::DeclTy *Sema::ActOnFunctionDefBody(DeclTy *D, StmtTy *Body) {
|
Sema::DeclTy *Sema::ActOnFinishFunctionBody(DeclTy *D, StmtTy *Body) {
|
||||||
FunctionDecl *FD = static_cast<FunctionDecl*>(D);
|
Decl *dcl = static_cast<Decl *>(D);
|
||||||
|
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(dcl)) {
|
||||||
FD->setBody((Stmt*)Body);
|
FD->setBody((Stmt*)Body);
|
||||||
|
|
||||||
assert(FD == CurFunctionDecl && "Function parsing confused");
|
assert(FD == CurFunctionDecl && "Function parsing confused");
|
||||||
|
} else if (ObjcMethodDecl *MD = dyn_cast<ObjcMethodDecl>(dcl)) {
|
||||||
|
MD->setBody((Stmt*)Body);
|
||||||
|
}
|
||||||
CurFunctionDecl = 0;
|
CurFunctionDecl = 0;
|
||||||
|
|
||||||
// Verify and clean out per-function state.
|
// Verify and clean out per-function state.
|
||||||
|
|
@ -1025,37 +1028,7 @@ Sema::DeclTy *Sema::ActOnFunctionDefBody(DeclTy *D, StmtTy *Body) {
|
||||||
}
|
}
|
||||||
LabelMap.clear();
|
LabelMap.clear();
|
||||||
|
|
||||||
return FD;
|
return D;
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ObjcActOnStartOfMethodDef - This routine sets up parameters; invisible
|
/// ObjcActOnStartOfMethodDef - This routine sets up parameters; invisible
|
||||||
|
|
|
||||||
|
|
@ -141,14 +141,10 @@ public:
|
||||||
|
|
||||||
/// ActOnFunctionDefBody - This is called when a function body has completed
|
/// ActOnFunctionDefBody - This is called when a function body has completed
|
||||||
/// parsing. Decl is the DeclTy returned by ParseStartOfFunctionDef.
|
/// parsing. Decl is the DeclTy returned by ParseStartOfFunctionDef.
|
||||||
virtual DeclTy *ActOnFunctionDefBody(DeclTy *Decl, StmtTy *Body) {
|
virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtTy *Body) {
|
||||||
return Decl;
|
return Decl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void ActOnMethodDefBody(DeclTy *Decl, StmtTy *Body) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ActOnPopScope - This callback is called immediately before the specified
|
/// ActOnPopScope - This callback is called immediately before the specified
|
||||||
/// scope is popped and deleted.
|
/// scope is popped and deleted.
|
||||||
virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {}
|
virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue