diff options
| author | Carlos Alberto Enciso <carlos.alberto.enciso@gmail.com> | 2018-03-26 13:48:03 +0000 |
|---|---|---|
| committer | Carlos Alberto Enciso <carlos.alberto.enciso@gmail.com> | 2018-03-26 13:48:03 +0000 |
| commit | 01ae6f2c5f0e48f42f9e8a66f2c9a02106034696 (patch) | |
| tree | 623a366f934aea3caeeb69e1ddba3193d20b8fcc /clang | |
| parent | ff9c1092b708d39f9dc99855f31d75b50c809c63 (diff) | |
| download | bcm5719-llvm-01ae6f2c5f0e48f42f9e8a66f2c9a02106034696.tar.gz bcm5719-llvm-01ae6f2c5f0e48f42f9e8a66f2c9a02106034696.zip | |
[SemaCXX] _Pragma("clang optimize off") not affecting lambda.
Declaring "_Pragma("clang optimize off")" before the body of a
function with a lambda leads to the lambda functions in the body
not being affected.
Differential Revision: https://reviews.llvm.org/D43821
llvm-svn: 328494
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaLambda.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/optnone-pragma-optimize-off.cpp | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index db8dd1793cf..1b9702f79ac 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -904,6 +904,10 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, ParamInfo.getDeclSpec().isConstexprSpecified()); if (ExplicitParams) CheckCXXDefaultArguments(Method); + + // This represents the function body for the lambda function, check if we + // have to apply optnone due to a pragma. + AddRangeBasedOptnone(Method); // Attributes on the lambda apply to the method. ProcessDeclAttributes(CurScope, Method, ParamInfo); diff --git a/clang/test/CodeGenCXX/optnone-pragma-optimize-off.cpp b/clang/test/CodeGenCXX/optnone-pragma-optimize-off.cpp new file mode 100644 index 00000000000..d750c4c2848 --- /dev/null +++ b/clang/test/CodeGenCXX/optnone-pragma-optimize-off.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -triple %itanium_abi_triple -O1 -disable-llvm-passes -emit-llvm -o - | FileCheck %s + +// Test the attributes for the lambda function contains 'optnone' as result of +// the _Pragma("clang optimize off"). + +_Pragma("clang optimize off") + +void foo(int p) { + auto lambda = [&p]() { ++p; }; + lambda(); + // CHECK: define {{.*}} @"_ZZ3fooiENK3$_0clEv"({{.*}}) #[[LAMBDA_ATR:[0-9]+]] +} + +_Pragma("clang optimize on") + +// CHECK: attributes #[[LAMBDA_ATR]] = { {{.*}} optnone {{.*}} }
\ No newline at end of file |

