diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2010-02-13 00:10:10 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2010-02-13 00:10:10 +0000 |
commit | c4a2638b5ef3e2d35d872614ceb655a7a22c58be (patch) | |
tree | 44205be72dc439218bc2d186683b4e803c71fa64 | |
parent | 4967762125eeb722cd65ba588d6f90b4a175e8c9 (diff) |
Fix for PR6274: teach constant folding to evaluate __builtin_expect.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96054 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ExprConstant.cpp | 7 | ||||
-rw-r--r-- | test/Sema/const-eval.c | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 382bfe59b5..1a44cd02d9 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -812,7 +812,7 @@ public: return false; } - bool VisitCallExpr(const CallExpr *E); + bool VisitCallExpr(CallExpr *E); bool VisitBinaryOperator(const BinaryOperator *E); bool VisitUnaryOperator(const UnaryOperator *E); bool VisitConditionalOperator(const ConditionalOperator *E); @@ -967,7 +967,7 @@ static int EvaluateBuiltinClassifyType(const CallExpr *E) { return -1; } -bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { +bool IntExprEvaluator::VisitCallExpr(CallExpr *E) { switch (E->isBuiltinCall(Info.Ctx)) { default: return Error(E->getLocStart(), diag::note_invalid_subexpr_in_ice, E); @@ -1022,6 +1022,9 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { Operand = Info.Ctx.Target.getEHDataRegisterNumber(Operand); return Success(Operand, E); } + + case Builtin::BI__builtin_expect: + return Visit(E->getArg(0)); } } diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index fee8d97f9b..9c537250a9 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -75,3 +75,4 @@ EVAL_EXPR(35, constbool) EVAL_EXPR(36, constbool) EVAL_EXPR(37, (1,2.0) == 2.0) +EVAL_EXPR(38, __builtin_expect(1,1) == 1) |