Skip to content
Snippets Groups Projects
Commit ca7c2eac authored by Nuno Lopes's avatar Nuno Lopes
Browse files

make IntExprEvaluator fold the ?: operator

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59421 91177308-0d34-0410-b5e6-96231b3b80d8
parent 3068d117
No related branches found
No related tags found
No related merge requests found
...@@ -397,6 +397,7 @@ public: ...@@ -397,6 +397,7 @@ public:
bool VisitCallExpr(const CallExpr *E); bool VisitCallExpr(const CallExpr *E);
bool VisitBinaryOperator(const BinaryOperator *E); bool VisitBinaryOperator(const BinaryOperator *E);
bool VisitUnaryOperator(const UnaryOperator *E); bool VisitUnaryOperator(const UnaryOperator *E);
bool VisitConditionalOperator(const ConditionalOperator *E);
bool VisitCastExpr(CastExpr* E) { bool VisitCastExpr(CastExpr* E) {
return HandleCast(E->getLocStart(), E->getSubExpr(), E->getType()); return HandleCast(E->getLocStart(), E->getSubExpr(), E->getType());
...@@ -725,6 +726,14 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { ...@@ -725,6 +726,14 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
return true; 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 /// VisitSizeAlignOfExpr - Evaluate a sizeof or alignof with a result as the
/// expression's type. /// expression's type.
bool IntExprEvaluator::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) { bool IntExprEvaluator::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment