builtins.
This fixes PR11711.
llvm-svn: 147655
unsigned BuiltinID, const CallExpr *E) {
// See if we can constant fold this builtin. If so, don't emit it at all.
Expr::EvalResult Result;
- if (E->EvaluateAsRValue(Result, CGM.getContext()) &&
+ if (!getContext().getLangOptions().NoBuiltin &&
+ E->EvaluateAsRValue(Result, CGM.getContext()) &&
!Result.hasSideEffects()) {
if (Result.Val.isInt())
return RValue::get(llvm::ConstantInt::get(getLLVMContext(),
--- /dev/null
+// RUN: %clang_cc1 -fno-builtin -emit-llvm %s -o - | FileCheck %s
+//
+// Check that -fno-builtin prevents us from constant-folding through builtins
+// (PR11711)
+
+double
+cos(double x)
+{
+ printf("ok\n");
+ exit(0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ cos(1); // CHECK: cos
+ printf("not ok\n");
+ abort();
+}
+