[cfe-commits] r60300 - /cfe/trunk/lib/AST/ExprConstant.cpp
Anders Carlsson
andersca at mac.com
Sun Nov 30 10:26:25 PST 2008
Author: andersca
Date: Sun Nov 30 12:26:25 2008
New Revision: 60300
URL: http://llvm.org/viewvc/llvm-project?rev=60300&view=rev
Log:
Replace the isEvaluated bool with a ShortCircuit int, making it easier to handle recursion
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=60300&r1=60299&r2=60300&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Nov 30 12:26:25 2008
@@ -41,13 +41,13 @@
/// EvalResult - Contains information about the evaluation.
Expr::EvalResult &EvalResult;
-
- /// isEvaluated - True if the subexpression is required to be evaluated, false
- /// if it is short-circuited (according to C rules).
- bool isEvaluated;
+
+ /// ShortCircuit - will be greater than zero if the current subexpression has
+ /// will not be evaluated because it's short-circuited (according to C rules).
+ unsigned ShortCircuit;
EvalInfo(ASTContext &ctx, Expr::EvalResult& evalresult) : Ctx(ctx),
- EvalResult(evalresult), isEvaluated(true) {}
+ EvalResult(evalresult), ShortCircuit(0) {}
};
@@ -339,7 +339,7 @@
bool Error(SourceLocation L, diag::kind D, const Expr *E) {
// If this is in an unevaluated portion of the subexpression, ignore the
// error.
- if (!Info.isEvaluated) {
+ if (Info.ShortCircuit) {
// If error is ignored because the value isn't evaluated, get the real
// type at least to prevent errors downstream.
Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
@@ -519,11 +519,7 @@
if (Visit(E->getRHS()))
return true;
- // Check for isEvaluated; the idea is that this might eventually
- // be useful for isICE and other similar uses that care about
- // whether a comma is evaluated. This isn't really used yet, though,
- // and I'm not sure it really works as intended.
- if (!Info.isEvaluated)
+ if (Info.ShortCircuit)
return Extension(E->getOperatorLoc(), diag::ext_comma_in_constant_expr,E);
return false;
@@ -543,8 +539,10 @@
Result.setIsUnsigned(E->getType()->isUnsignedIntegerType());
Result = lhsResult;
+ Info.ShortCircuit++;
bool rhsEvaluated = HandleConversionToBool(E->getRHS(), rhsResult, Info);
-
+ Info.ShortCircuit--;
+
if (rhsEvaluated)
return true;
More information about the cfe-commits
mailing list