[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / CodeGenCXX / lambda-expressions-nested-linkage.cpp
blob18d2080a611e847b96f30cf773905e979714cc90
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++14 | FileCheck --check-prefixes=CHECK,CXX14 %s
4 // CHECK-LABEL: define{{.*}} void @_ZN19non_inline_function3fooEv()
5 // CHECK-LABEL: define internal void @"_ZZN19non_inline_function3fooEvENK3$_0clEi"(ptr
6 // CHECK-LABEL: define internal noundef signext i8 @"_ZZZN19non_inline_function3fooEvENK3$_0clEiENKUlcE_clEc"(ptr
7 namespace non_inline_function {
8 void foo() {
9 auto L = [](int a) {
10 return [](char b) {
11 return b;
14 L(3)('a');
18 namespace non_template {
19 struct L {
20 int t = ([](int a) { return [](int b) { return b; };})(2)(3);
22 L l;
25 // It's important that this is not in a namespace; we're testing the mangling
26 // of lambdas in top-level inline variables here.
27 inline auto lambda_in_inline_variable = [] {};
28 template<typename T> struct Wrap {};
29 // CHECK-LABEL: define {{.*}} @_Z30test_lambda_in_inline_variable4WrapIN25lambda_in_inline_variableMUlvE_EE
30 void test_lambda_in_inline_variable(Wrap<decltype(lambda_in_inline_variable)>) {}
32 namespace lambdas_in_NSDMIs_template_class {
33 template<class T>
34 struct L {
35 T t2 = ([](int a) { return [](int b) { return b; };})(T{})(T{});
37 L<int> l;
40 // CHECK-LABEL: define linkonce_odr noundef i32 @_ZN15inline_function3fooEv
42 // CHECK-LABEL: define linkonce_odr void @_ZNK12non_template1L1tMUliE_clEi(ptr
43 // CHECK-LABEL: define linkonce_odr noundef i32 @_ZZNK12non_template1L1tMUliE_clEiENKUliE_clEi(ptr
46 // CHECK-LABEL: define linkonce_odr void @_ZNK32lambdas_in_NSDMIs_template_class1LIiEUliE_clEi(ptr
47 // CHECK-LABEL: define linkonce_odr noundef i32 @_ZZNK32lambdas_in_NSDMIs_template_class1LIiEUliE_clEiENKUliE_clEi(ptr
49 // CHECK-LABEL: define linkonce_odr void @_ZZN15inline_function3fooEvENKUliE_clEi
50 // CHECK-LABEL: define linkonce_odr noundef signext i8 @_ZZZN15inline_function3fooEvENKUliE_clEiENKUlcE_clEc
51 namespace inline_function {
52 inline int foo() {
53 auto L = [](int a) {
54 return [](char b) {
55 return b;
58 L(3)('a');
60 int use = foo();
63 #if __cplusplus >= 201402L
64 // CXX14-LABEL: define internal void @"_ZZZN32lambda_capture_in_generic_lambda3fooIiEEDavENKUlT_E_clIZNS_L1fEvE3$_0EEDaS1_ENKUlvE_clEv"
65 namespace lambda_capture_in_generic_lambda {
66 template <typename T> auto foo() {
67 return [](auto func) {
68 [func] { func(); }();
71 static void f() {
72 foo<int>()([] { });
74 void f1() { f(); }
76 #endif