aboutsummaryrefslogtreecommitdiff
path: root/Parse/Parser.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2007-11-10 16:31:34 +0000
committerFariborz Jahanian <fjahanian@apple.com>2007-11-10 16:31:34 +0000
commit60fbca0b027ff5a6579f16cb6e3abab826e0d967 (patch)
tree6366da8adafac6f58e38a0381e025eb273b6027b /Parse/Parser.cpp
parenteae5cd010e41c90da72a2f9d49cff579e6adba35 (diff)
Represent method definitions as separate AST nodes. Pretty print will come next.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43979 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Parse/Parser.cpp')
-rw-r--r--Parse/Parser.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp
index cfa92e1020..1f8e016bfe 100644
--- a/Parse/Parser.cpp
+++ b/Parse/Parser.cpp
@@ -330,17 +330,17 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() {
// @ is not a legal token unless objc is enabled, no need to check.
return ParseObjCAtDirectives();
case tok::minus:
- if (getLang().ObjC1) {
- return ParseObjCInstanceMethodDefinition();
- } else {
+ if (getLang().ObjC1)
+ ParseObjCInstanceMethodDefinition();
+ else {
Diag(Tok, diag::err_expected_external_declaration);
ConsumeToken();
}
return 0;
case tok::plus:
- if (getLang().ObjC1) {
- return ParseObjCClassMethodDefinition();
- } else {
+ if (getLang().ObjC1)
+ ParseObjCClassMethodDefinition();
+ else {
Diag(Tok, diag::err_expected_external_declaration);
ConsumeToken();
}
@@ -467,7 +467,7 @@ Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) {
/// ObjcParseMethodDefinition - This routine parses a method definition and
/// returns its AST.
-Parser::DeclTy *Parser::ObjcParseMethodDefinition(DeclTy *D) {
+void Parser::ObjcParseMethodDefinition(DeclTy *D) {
// We should have an opening brace now.
if (Tok.isNot(tok::l_brace)) {
Diag(Tok, diag::err_expected_fn_body);
@@ -477,7 +477,7 @@ Parser::DeclTy *Parser::ObjcParseMethodDefinition(DeclTy *D) {
// If we didn't find the '{', bail out.
if (Tok.isNot(tok::l_brace))
- return 0;
+ return;
}
SourceLocation BraceLoc = Tok.getLocation();
@@ -487,9 +487,19 @@ Parser::DeclTy *Parser::ObjcParseMethodDefinition(DeclTy *D) {
// Tell the actions module that we have entered a method definition with the
// specified Declarator for the method.
- DeclTy *Res = Actions.ObjcActOnStartOfMethodDef(CurScope, D);
+ Actions.ObjcActOnStartOfMethodDef(CurScope, D);
- return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc);
+ StmtResult FnBody = ParseCompoundStatementBody();
+
+ // If the function body could not be parsed, make a bogus compoundstmt.
+ if (FnBody.isInvalid)
+ FnBody = Actions.ActOnCompoundStmt(BraceLoc, BraceLoc, 0, 0, false);
+
+ // Leave the function body scope.
+ ExitScope();
+
+ // TODO: Pass argument information.
+ Actions.ActOnMethodDefBody(D, FnBody.Val);
}
/// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides