[cfe-commits] r66113 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseCXXInlineMethods.cpp lib/Parse/ParseStmt.cpp lib/Parse/Parser.cpp

Chris Lattner sabre at nondot.org
Wed Mar 4 16:49:17 PST 2009


Author: lattner
Date: Wed Mar  4 18:49:17 2009
New Revision: 66113

URL: http://llvm.org/viewvc/llvm-project?rev=66113&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=66113&r1=66112&r2=66113&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar  4 18:49:17 2009
@@ -788,8 +788,7 @@
   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, 

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=66113&r1=66112&r2=66113&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Wed Mar  4 18:49:17 2009
@@ -136,8 +136,8 @@
 
     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);
   }
 }
 

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=66113&r1=66112&r2=66113&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Wed Mar  4 18:49:17 2009
@@ -1284,8 +1284,10 @@
   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 @@
 
   // 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));
 }

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=66113&r1=66112&r2=66113&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Wed Mar  4 18:49:17 2009
@@ -590,7 +590,7 @@
     ParseConstructorInitializer(Res);
 
   SourceLocation BraceLoc = Tok.getLocation();
-  return ParseFunctionStatementBody(Res, BraceLoc, BraceLoc);
+  return ParseFunctionStatementBody(Res);
 }
 
 /// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides





More information about the cfe-commits mailing list