diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-02-21 18:14:20 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-21 18:14:20 +0000 |
commit | 79e042a8b5a76fd8ce1d42cb67df8fe7d9fc9876 (patch) | |
tree | 9fd0df5effedcba80b71ada5dfb388d98366a866 /clang/lib/AST/ExprConstant.cpp | |
parent | 4fc88b779ea12f4300c40889b87647aab6030514 (diff) | |
download | bcm5719-llvm-79e042a8b5a76fd8ce1d42cb67df8fe7d9fc9876.tar.gz bcm5719-llvm-79e042a8b5a76fd8ce1d42cb67df8fe7d9fc9876.zip |
Evaluation of unary deref could call integer evaluator on non-integral
expr; hilarity ensued.
- PR3640.
llvm-svn: 65234
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 64d3fdd8a73..e3c48091b5e 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/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; |