[cfe-commits] r72257 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseExprCXX.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Fri May 22 03:23:18 PDT 2009


Author: akirtzidis
Date: Fri May 22 05:23:16 2009
New Revision: 72257

URL: http://llvm.org/viewvc/llvm-project?rev=72257&view=rev
Log:
Remove ParseSimpleParenExpression.
Embed its functionality into it's only user, ParseCXXCasts.
CXXCasts now get the "actual" expression directly, they no longer always receive a ParenExpr. This is better since the
parentheses are always part of the C++ casts syntax.

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

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri May 22 05:23:16 2009
@@ -688,16 +688,6 @@
   OwningExprResult ParseParenExpression(ParenParseOption &ExprType,
                                         TypeTy *&CastTy,
                                         SourceLocation &RParenLoc);
-
-  OwningExprResult ParseSimpleParenExpression() {  // Parse SimpleExpr only.
-    SourceLocation RParenLoc;
-    return ParseSimpleParenExpression(RParenLoc);
-  }
-  OwningExprResult ParseSimpleParenExpression(SourceLocation &RParenLoc) {
-    ParenParseOption Op = SimpleExpr;
-    TypeTy *CastTy;
-    return ParseParenExpression(Op, CastTy, RParenLoc);
-  }
   
   OwningExprResult ParseStringLiteralExpression();
 

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri May 22 05:23:16 2009
@@ -322,10 +322,19 @@
 
   SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
 
-  if (Tok.isNot(tok::l_paren))
-    return ExprError(Diag(Tok, diag::err_expected_lparen_after) << CastName);
+  if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after, CastName))
+    return ExprError();
 
-  OwningExprResult Result(ParseSimpleParenExpression(RParenLoc));
+  OwningExprResult Result = ParseExpression();
+  
+  // Match the ')'.
+  if (Result.isInvalid())
+    SkipUntil(tok::r_paren);
+  
+  if (Tok.is(tok::r_paren))
+    RParenLoc = ConsumeParen();
+  else
+    MatchRHSPunctuation(tok::r_paren, LParenLoc);
 
   if (!Result.isInvalid() && !CastTy.isInvalid())
     Result = Actions.ActOnCXXNamedCast(OpLoc, Kind,





More information about the cfe-commits mailing list