[cfe-commits] r39677 - in /cfe/cfe/trunk: Parse/ParseStmt.cpp include/clang/Parse/Action.h
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:47:03 PDT 2007
Author: clattner
Date: Wed Jul 11 11:47:02 2007
New Revision: 39677
URL: http://llvm.org/viewvc/llvm-project?rev=39677&view=rev
Log:
Start bringing the exprstmt hook back.
Modified:
cfe/cfe/trunk/Parse/ParseStmt.cpp
cfe/cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseStmt.cpp?rev=39677&r1=39676&r2=39677&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseStmt.cpp Wed Jul 11 11:47:02 2007
@@ -101,7 +101,7 @@
}
// Otherwise, eat the semicolon.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
- return Res.Val;
+ return Actions.ParseExprStmt(Res.Val);
}
case tok::kw_case: // C99 6.8.1: labeled-statement
@@ -249,7 +249,8 @@
return true;
} else {
ConsumeToken();
- return Res.Val;
+ // Convert expr to a stmt.
+ return Actions.ParseExprStmt(Res.Val);
}
}
@@ -575,7 +576,8 @@
ExprResult Value;
StmtTy *FirstPart = 0;
- ExprTy *SecondPart = 0, *ThirdPart = 0;
+ ExprTy *SecondPart = 0;
+ StmtTy *ThirdPart = 0;
// Parse the first part of the for specifier.
if (Tok.getKind() == tok::semi) { // for (;
@@ -591,8 +593,12 @@
} else {
Value = ParseExpression();
- if (!Value.isInvalid)
- FirstPart = Value.Val;
+ // Turn the expression into a stmt.
+ if (!Value.isInvalid) {
+ StmtResult R = Actions.ParseExprStmt(Value.Val);
+ if (!R.isInvalid)
+ FirstPart = R.Val;
+ }
if (Tok.getKind() == tok::semi) {
ConsumeToken();
@@ -625,8 +631,12 @@
Value = ExprResult();
} else {
Value = ParseExpression();
- if (!Value.isInvalid)
- ThirdPart = Value.Val;
+ if (!Value.isInvalid) {
+ // Turn the expression into a stmt.
+ StmtResult R = Actions.ParseExprStmt(Value.Val);
+ if (!R.isInvalid)
+ ThirdPart = R.Val;
+ }
}
// Match the ')'.
Modified: cfe/cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/Action.h?rev=39677&r1=39676&r2=39677&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/Action.h Wed Jul 11 11:47:02 2007
@@ -192,6 +192,10 @@
return 0;
}
+ virtual StmtResult ParseExprStmt(ExprTy *Expr) {
+ return StmtResult(Expr);
+ }
+
/// ParseCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,
/// which can specify an RHS value.
virtual StmtResult ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
More information about the cfe-commits
mailing list