aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-21 18:14:20 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-21 18:14:20 +0000
commit4fff4819a913c65ae23cfd389bc47c61919e4e1f (patch)
tree8ce65617b91cf5c1c9d9cd27fe81326113378ebf /lib/AST/ExprConstant.cpp
parent61490e9a965cfee8a78c12c6802138844f04250d (diff)
Evaluation of unary deref could call integer evaluator on non-integral
expr; hilarity ensued. - PR3640. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65234 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 64d3fdd8a7..e3c48091b5 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -490,6 +490,7 @@ public:
}
bool Success(const llvm::APSInt &SI, const Expr *E) {
+ assert(E->getType()->isIntegralType() && "Invalid evaluation result.");
assert(SI.isSigned() == E->getType()->isSignedIntegerType() &&
"Invalid evaluation result.");
assert(SI.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) &&
@@ -499,6 +500,7 @@ public:
}
bool Success(const llvm::APInt &I, const Expr *E) {
+ assert(E->getType()->isIntegralType() && "Invalid evaluation result.");
assert(I.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) &&
"Invalid evaluation result.");
Result = APValue(APSInt(I));
@@ -507,6 +509,7 @@ public:
}
bool Success(uint64_t Value, const Expr *E) {
+ assert(E->getType()->isIntegralType() && "Invalid evaluation result.");
Result = APValue(Info.Ctx.MakeIntValue(Value, E->getType()));
return true;
}
@@ -1027,6 +1030,10 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
return Success(!bres, E);
}
+ // Only handle integral operations...
+ if (!E->getSubExpr()->getType()->isIntegralType())
+ return false;
+
// Get the operand value into 'Result'.
if (!Visit(E->getSubExpr()))
return false;