Refactored parsing of main function body for reuse by objective-c methods.
llvm-svn: 43898
diff --git a/clang/Parse/ParseStmt.cpp b/clang/Parse/ParseStmt.cpp
index 5e05f9a..6836f10 100644
--- a/clang/Parse/ParseStmt.cpp
+++ b/clang/Parse/ParseStmt.cpp
@@ -1030,3 +1030,21 @@
ConsumeToken();
}
}
+
+Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl,
+ SourceLocation L, SourceLocation R) {
+ // Do not enter a scope for the brace, as the arguments are in the same scope
+ // (the function body) as the body itself. Instead, just read the statement
+ // list and put it into a CompoundStmt for safe keeping.
+ StmtResult FnBody = ParseCompoundStatementBody();
+
+ // If the function body could not be parsed, make a bogus compoundstmt.
+ if (FnBody.isInvalid)
+ FnBody = Actions.ActOnCompoundStmt(L, R, 0, 0, false);
+
+ // Leave the function body scope.
+ ExitScope();
+
+ // TODO: Pass argument information.
+ return Actions.ActOnFunctionDefBody(Decl, FnBody.Val);
+}
\ No newline at end of file