diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2008-11-16 19:28:31 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2008-11-16 19:28:31 +0000 |
commit | 420426100cbdb2d8d18cbca2914625cdebc5bef8 (patch) | |
tree | d97747c52d49a4682bf7424f6a1c64476a093d5c /clang/lib/AST/ExprConstant.cpp | |
parent | 9f9e4249cc90ed4476b9c79dd8772e265dd30035 (diff) | |
download | bcm5719-llvm-420426100cbdb2d8d18cbca2914625cdebc5bef8.tar.gz bcm5719-llvm-420426100cbdb2d8d18cbca2914625cdebc5bef8.zip |
make IntExprEvaluator fold the ?: operator
llvm-svn: 59421
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 4a679567498..bedc78c0c05 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -397,6 +397,7 @@ public: bool VisitCallExpr(const CallExpr *E); bool VisitBinaryOperator(const BinaryOperator *E); bool VisitUnaryOperator(const UnaryOperator *E); + bool VisitConditionalOperator(const ConditionalOperator *E); bool VisitCastExpr(CastExpr* E) { return HandleCast(E->getLocStart(), E->getSubExpr(), E->getType()); @@ -725,6 +726,14 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { return true; } +bool IntExprEvaluator::VisitConditionalOperator(const ConditionalOperator *E) { + llvm::APSInt Cond(32); + if (!EvaluateInteger(E->getCond(), Cond, Info)) + return false; + + return Visit(Cond != 0 ? E->getTrueExpr() : E->getFalseExpr()); +} + /// VisitSizeAlignOfExpr - Evaluate a sizeof or alignof with a result as the /// expression's type. bool IntExprEvaluator::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) { |