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
diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp
index cfa92e1..1f8e016 100644
--- a/Parse/Parser.cpp
+++ b/Parse/Parser.cpp
@@ -330,17 +330,17 @@
     // @ 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 @@
 
 /// 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 @@
     
     // 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 @@
   
   // 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