[cfe-commits] r43898 - in /cfe/trunk: Parse/ParseStmt.cpp Parse/Parser.cpp include/clang/Parse/Parser.h
Fariborz Jahanian
fjahanian at apple.com
Thu Nov 8 11:01:27 PST 2007
Author: fjahanian
Date: Thu Nov 8 13:01:26 2007
New Revision: 43898
URL: http://llvm.org/viewvc/llvm-project?rev=43898&view=rev
Log:
Refactored parsing of main function body for reuse by objective-c methods.
Modified:
cfe/trunk/Parse/ParseStmt.cpp
cfe/trunk/Parse/Parser.cpp
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=43898&r1=43897&r2=43898&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/Parse/ParseStmt.cpp Thu Nov 8 13:01:26 2007
@@ -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
Modified: cfe/trunk/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/Parser.cpp?rev=43898&r1=43897&r2=43898&view=diff
==============================================================================
--- cfe/trunk/Parse/Parser.cpp (original)
+++ cfe/trunk/Parse/Parser.cpp Thu Nov 8 13:01:26 2007
@@ -462,21 +462,7 @@
// 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
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=43898&r1=43897&r2=43898&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Nov 8 13:01:26 2007
@@ -397,6 +397,8 @@
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);
More information about the cfe-commits
mailing list