[cfe-commits] r103238 - /cfe/trunk/lib/AST/ExprConstant.cpp
John McCall
rjmccall at apple.com
Thu May 6 22:46:36 PDT 2010
Author: rjmccall
Date: Fri May 7 00:46:35 2010
New Revision: 103238
URL: http://llvm.org/viewvc/llvm-project?rev=103238&view=rev
Log:
Change Evaluate* in the constant evaluator to enforce being given an argument of
the right type. It turns out that the code was already doing this.
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=103238&r1=103237&r2=103238&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 7 00:46:35 2010
@@ -395,8 +395,7 @@
} // end anonymous namespace
static bool EvaluatePointer(const Expr* E, APValue& Result, EvalInfo &Info) {
- if (!E->getType()->hasPointerRepresentation())
- return false;
+ assert(E->getType()->hasPointerRepresentation());
Result = PointerExprEvaluator(Info).Visit(const_cast<Expr*>(E));
return Result.isLValue();
}
@@ -872,13 +871,13 @@
} // end anonymous namespace
static bool EvaluateIntegerOrLValue(const Expr* E, APValue &Result, EvalInfo &Info) {
- if (!E->getType()->isIntegralType())
- return false;
-
+ assert(E->getType()->isIntegralType());
return IntExprEvaluator(Info, Result).Visit(const_cast<Expr*>(E));
}
static bool EvaluateInteger(const Expr* E, APSInt &Result, EvalInfo &Info) {
+ assert(E->getType()->isIntegralType());
+
APValue Val;
if (!EvaluateIntegerOrLValue(E, Val, Info) || !Val.isInt())
return false;
@@ -1656,6 +1655,7 @@
} // end anonymous namespace
static bool EvaluateFloat(const Expr* E, APFloat& Result, EvalInfo &Info) {
+ assert(E->getType()->isRealFloatingType());
return FloatExprEvaluator(Info, Result).Visit(const_cast<Expr*>(E));
}
@@ -1977,6 +1977,7 @@
} // end anonymous namespace
static bool EvaluateComplex(const Expr *E, APValue &Result, EvalInfo &Info) {
+ assert(E->getType()->isAnyComplexType());
Result = ComplexExprEvaluator(Info).Visit(const_cast<Expr*>(E));
assert((!Result.isComplexFloat() ||
(&Result.getComplexFloatReal().getSemantics() ==
More information about the cfe-commits
mailing list