First patch toward rewriting of method definitions. This is work in progress.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43915 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp
index a2ba86e..59a077d 100644
--- a/Parse/Parser.cpp
+++ b/Parse/Parser.cpp
@@ -331,7 +331,7 @@
return ParseObjCAtDirectives();
case tok::minus:
if (getLang().ObjC1) {
- ParseObjCInstanceMethodDefinition();
+ return ParseObjCInstanceMethodDefinition();
} else {
Diag(Tok, diag::err_expected_external_declaration);
ConsumeToken();
@@ -339,7 +339,7 @@
return 0;
case tok::plus:
if (getLang().ObjC1) {
- ParseObjCClassMethodDefinition();
+ return ParseObjCClassMethodDefinition();
} else {
Diag(Tok, diag::err_expected_external_declaration);
ConsumeToken();
@@ -465,6 +465,31 @@
return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc);
}
+Parser::DeclTy *Parser::ObjcParseFunctionDefinition(DeclTy *D) {
+ // We should have an opening brace now.
+ if (Tok.isNot(tok::l_brace)) {
+ Diag(Tok, diag::err_expected_fn_body);
+
+ // Skip over garbage, until we get to '{'. Don't eat the '{'.
+ SkipUntil(tok::l_brace, true, true);
+
+ // If we didn't find the '{', bail out.
+ if (Tok.isNot(tok::l_brace))
+ return 0;
+ }
+
+ SourceLocation BraceLoc = Tok.getLocation();
+
+ // Enter a scope for the function body.
+ EnterScope(Scope::FnScope|Scope::DeclScope);
+
+ // Tell the actions module that we have entered a function definition with the
+ // specified Declarator for the function.
+ DeclTy *Res = Actions.ObjcActOnStartOfFunctionDef(CurScope, D);
+
+ return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc);
+}
+
/// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides
/// types for a function with a K&R-style identifier list for arguments.
void Parser::ParseKNRParamDeclarations(Declarator &D) {