]> granicus.if.org Git - clang/commitdiff
Refactored parsing of main function body for reuse by objective-c methods.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 8 Nov 2007 19:01:26 +0000 (19:01 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 8 Nov 2007 19:01:26 +0000 (19:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43898 91177308-0d34-0410-b5e6-96231b3b80d8

Parse/ParseStmt.cpp
Parse/Parser.cpp
include/clang/Parse/Parser.h

index 5e05f9a27d2e83e883843e2fea6c4da833afdcfa..6836f10c58473dbf75a6324bfc0fa81ae98b2729 100644 (file)
@@ -1030,3 +1030,21 @@ void Parser::ParseAsmOperandsOpt() {
     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
index 8040eb8ebc4b0fdffa324e8bb41b6e4c726ddd04..a2ba86e9035ce058fda5f95a6cfae17fce4a5f76 100644 (file)
@@ -462,21 +462,7 @@ Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) {
   // specified Declarator for the function.
   DeclTy *Res = Actions.ActOnStartOfFunctionDef(CurScope, D);
   
-  
-  // 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(BraceLoc, BraceLoc, 0, 0, false);
-
-  // Leave the function body scope.
-  ExitScope();
-
-  // TODO: Pass argument information.
-  return Actions.ActOnFunctionDefBody(Res, FnBody.Val);
+  return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc);  
 }
 
 /// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides
index b7476a77b60c143b61c62102d523f3cae1c7220b..7339d6ca5041b37c4da93f117c91728046491d77 100644 (file)
@@ -397,6 +397,8 @@ private:
   DeclTy *ParseDeclaration(unsigned Context);
   DeclTy *ParseSimpleDeclaration(unsigned Context);
   DeclTy *ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D);
+  DeclTy *ParseFunctionStatementBody(DeclTy *Decl, 
+                                     SourceLocation L, SourceLocation R);
   void ParseDeclarationSpecifiers(DeclSpec &DS);
   void ParseSpecifierQualifierList(DeclSpec &DS);