[cfe-commits] r96054 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/const-eval.c

Eli Friedman eli.friedman at gmail.com
Fri Feb 12 16:10:10 PST 2010


Author: efriedma
Date: Fri Feb 12 18:10:10 2010
New Revision: 96054

URL: http://llvm.org/viewvc/llvm-project?rev=96054&view=rev
Log:
Fix for PR6274: teach constant folding to evaluate __builtin_expect.


Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/test/Sema/const-eval.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=96054&r1=96053&r2=96054&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb 12 18:10:10 2010
@@ -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));
   }
 }
 

Modified: cfe/trunk/test/Sema/const-eval.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/const-eval.c?rev=96054&r1=96053&r2=96054&view=diff

==============================================================================
--- cfe/trunk/test/Sema/const-eval.c (original)
+++ cfe/trunk/test/Sema/const-eval.c Fri Feb 12 18:10:10 2010
@@ -75,3 +75,4 @@
 EVAL_EXPR(36, constbool)
 
 EVAL_EXPR(37, (1,2.0) == 2.0)
+EVAL_EXPR(38, __builtin_expect(1,1) == 1)





More information about the cfe-commits mailing list