diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-05 00:49:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-05 00:49:17 +0000 |
commit | 40e9bc84a2ab49fc33c2b1a95c6674ab2b820e9e (patch) | |
tree | 295c22faaaedd440c116a7f076430195af52d9c5 | |
parent | 852157601505e0a641f1b66c9e2fb028f77bb7d1 (diff) |
Simplify the interface to ParseFunctionStatementBody to not take
locations that are the current tok loc. Note that inline C++ methods
have a big fixme that could cause a crash.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66113 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Parse/Parser.h | 3 | ||||
-rw-r--r-- | lib/Parse/ParseCXXInlineMethods.cpp | 4 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 9 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 2 |
4 files changed, 10 insertions, 8 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 5d5265df35..4efde44d1e 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -788,8 +788,7 @@ private: DeclTy *ParseDeclaration(unsigned Context); DeclTy *ParseSimpleDeclaration(unsigned Context); DeclTy *ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D); - DeclTy *ParseFunctionStatementBody(DeclTy *Decl, - SourceLocation L, SourceLocation R); + DeclTy *ParseFunctionStatementBody(DeclTy *Decl); void ParseDeclarationSpecifiers(DeclSpec &DS, TemplateParameterLists *TemplateParams = 0); bool ParseOptionalTypeSpecifier(DeclSpec &DS, int &isInvalid, diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index 4aa923ca00..cc61f0f6fd 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -136,8 +136,8 @@ void Parser::ParseLexedMethodDefs() { if (Tok.is(tok::colon)) ParseConstructorInitializer(LM.D); - - ParseFunctionStatementBody(LM.D, Tok.getLocation(), Tok.getLocation()); + // FIXME: What if ParseConstructorInitializer doesn't leave us with a '{'?? + ParseFunctionStatementBody(LM.D); } } diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 4f7affc69c..1ecbe8bd84 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1284,8 +1284,10 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names, return true; } -Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl, - SourceLocation L, SourceLocation R) { +Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl) { + assert(Tok.is(tok::l_brace)); + SourceLocation LBraceLoc = Tok.getLocation(); + // 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. @@ -1293,7 +1295,8 @@ Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl, // If the function body could not be parsed, make a bogus compoundstmt. if (FnBody.isInvalid()) - FnBody = Actions.ActOnCompoundStmt(L, R, MultiStmtArg(Actions), false); + FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc, + MultiStmtArg(Actions), false); return Actions.ActOnFinishFunctionBody(Decl, move(FnBody)); } diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 30db5e6759..3cdaab6e88 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -590,7 +590,7 @@ Parser::DeclTy *Parser::ParseFunctionDefinition(Declarator &D) { ParseConstructorInitializer(Res); SourceLocation BraceLoc = Tok.getLocation(); - return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc); + return ParseFunctionStatementBody(Res); } /// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides |