Evaluation of unary deref could call integer evaluator on non-integral

expr; hilarity ensued.
 - PR3640.

llvm-svn: 65234
This commit is contained in:
Daniel Dunbar 2009-02-21 18:14:20 +00:00
parent 4fc88b779e
commit 79e042a8b5
2 changed files with 9 additions and 0 deletions

View File

@ -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;

View File

@ -40,3 +40,5 @@ struct s {
};
EVAL_EXPR(19, ((int)&*(char*)10 == 10 ? 1 : -1));
EVAL_EXPR(20, __builtin_constant_p(*((int*) 10), -1, 1));