[PATCH] Constant expression evaluation support for __builtin_isinf

Richard Smith richard at metafoo.co.uk
Wed Oct 2 12:11:06 PDT 2013



================
Comment at: lib/AST/ExprConstant.cpp:5988-5992
@@ -5987,1 +5987,7 @@
+  
+  case Builtin::BI__builtin_isinf: {
+    APFloat Val(0.0);
+    return EvaluateFloat(E->getArg(0), Val, Info) &&
+           Success(Val.isInfinity() ? 1 : 0, E);
+  }
 
----------------
Do you have any interest in implementing isfinite, isnan and isnormal too?

================
Comment at: test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp:134-149
@@ +133,17 @@
+
+// __builtin_isinf
+inline constexpr bool
+isinf(long double __x) { 
+  return __builtin_isinf(__x);
+}
+
+inline constexpr bool
+isinf(double __x) { 
+  return __builtin_isinf(__x); 
+}
+
+void test_builtin_isinf() {
+  constexpr long double num1 = __builtin_isinf(1.l); // No error
+  constexpr long double num2 = isinf(1.l);           // No error
+  constexpr double num3 = isinf(1.);                 // No error
+}
----------------
These tests should go with the other tests for similar builtins in test/Sema/constant-builtins-2.c, not here.


http://llvm-reviews.chandlerc.com/D1794



More information about the cfe-commits mailing list