зеркало из https://github.com/microsoft/clang-1.git
If we are compiling with -fno-builtin then don't do constant folding of
builtins. This fixes PR11711. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147655 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
092beef87b
Коммит
843cc5aaed
|
@ -175,7 +175,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
|
|||
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(),
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// 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();
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче