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
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 382bfe5..1a44cd0 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -812,7 +812,7 @@
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 @@
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 @@
Operand = Info.Ctx.Target.getEHDataRegisterNumber(Operand);
return Success(Operand, E);
}
+
+ case Builtin::BI__builtin_expect:
+ return Visit(E->getArg(0));
}
}