From 17c7957f023f02fc2c88f51f8908c19b52609275 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Fri, 25 Nov 2016 19:07:40 +0000 Subject: Vendor import of clang release_39 branch r287912: https://llvm.org/svn/llvm-project/cfe/branches/release_39@287912 --- test/CodeGenCXX/PR28523.cpp | 19 +++++++ test/CodeGenCXX/captured-statements.cpp | 1 + test/CodeGenCXX/switch-case-folding-2.cpp | 82 ++++++++++++++++++++++++++++++- 3 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 test/CodeGenCXX/PR28523.cpp (limited to 'test/CodeGenCXX') diff --git a/test/CodeGenCXX/PR28523.cpp b/test/CodeGenCXX/PR28523.cpp new file mode 100644 index 000000000000..4c3a81c8b854 --- /dev/null +++ b/test/CodeGenCXX/PR28523.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=c++14 -verify -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s +// expected-no-diagnostics + +template void parallel_loop(F &&f) { f(0); } + +//CHECK-LABEL: @main +int main() { +// CHECK: [[X_ADDR:%.+]] = alloca i32, + int x; +// CHECK: getelementptr inbounds +// CHECK: store i32* [[X_ADDR]], i32** % +// CHECK: call + parallel_loop([&](auto y) { +#pragma clang __debug captured + { + x = y; + }; + }); +} diff --git a/test/CodeGenCXX/captured-statements.cpp b/test/CodeGenCXX/captured-statements.cpp index fdda24fcf301..4b95503ad7b3 100644 --- a/test/CodeGenCXX/captured-statements.cpp +++ b/test/CodeGenCXX/captured-statements.cpp @@ -78,6 +78,7 @@ void test3(int x) { { x = [=]() { return x + 1; } (); } + x = [=]() { return x + 1; }(); // CHECK-3: %[[Capture:struct\.anon[\.0-9]*]] = type { i32* } diff --git a/test/CodeGenCXX/switch-case-folding-2.cpp b/test/CodeGenCXX/switch-case-folding-2.cpp index 558ca3c87d9b..cfb8447ee326 100644 --- a/test/CodeGenCXX/switch-case-folding-2.cpp +++ b/test/CodeGenCXX/switch-case-folding-2.cpp @@ -1,12 +1,14 @@ // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s -// CHECK that we don't crash. extern int printf(const char*, ...); + +// CHECK-LABEL: @_Z4testi( int test(int val){ switch (val) { case 4: do { switch (6) { + // CHECK: call i32 (i8*, ...) @_Z6printfPKcz case 6: do { case 5: printf("bad\n"); } while (0); }; } while (0); @@ -18,6 +20,7 @@ int main(void) { return test(5); } +// CHECK-LABEL: @_Z10other_testv( void other_test() { switch(0) { case 0: @@ -27,4 +30,79 @@ void other_test() { } } -// CHECK: call i32 (i8*, ...) @_Z6printfPKcz +struct X { X(); ~X(); }; + +void dont_call(); +void foo(); + +// CHECK-LABEL: @_Z13nested_scopesv( +void nested_scopes() { + switch (1) { + case 0: + // CHECK-NOT: @_Z9dont_callv( + dont_call(); + break; + + default: + // CHECK: call {{.*}} @_ZN1XC1Ev( + // CHECK: call {{.*}} @_Z3foov( + // CHECK-NOT: call {{.*}} @_Z3foov( + // CHECK: call {{.*}} @_ZN1XD1Ev( + { X x; foo(); } + + // CHECK: call {{.*}} @_ZN1XC1Ev( + // CHECK: call {{.*}} @_Z3foov( + // CHECK: call {{.*}} @_ZN1XD1Ev( + { X x; foo(); } + + // CHECK: call {{.*}} @_ZN1XC1Ev( + // CHECK: call {{.*}} @_Z3foov( + // CHECK: call {{.*}} @_ZN1XD1Ev( + { X x; foo(); } + break; + } +} + +// CHECK-LABEL: @_Z17scope_fallthroughv( +void scope_fallthrough() { + switch (1) { + // CHECK: call {{.*}} @_ZN1XC1Ev( + // CHECK-NOT: call {{.*}} @_Z3foov( + // CHECK: call {{.*}} @_ZN1XD1Ev( + { default: X x; } + // CHECK: call {{.*}} @_Z3foov( + foo(); + break; + } +} + +// CHECK-LABEL: @_Z12hidden_breakb( +void hidden_break(bool b) { + switch (1) { + default: + // CHECK: br + if (b) + break; + // CHECK: call {{.*}} @_Z3foov( + foo(); + break; + } +} + +// CHECK-LABEL: @_Z10hidden_varv( +int hidden_var() { + switch (1) { + // CHECK: %[[N:.*]] = alloca i32 + case 0: int n; + // CHECK: store i32 0, i32* %[[N]] + // CHECK: load i32, i32* %[[N]] + // CHECK: ret + default: n = 0; return n; + } +} + +// CHECK-LABEL: @_Z13case_in_labelv( +void case_in_label() { + // CHECK: br label % + switch (1) case 1: foo: case 0: goto foo; +} -- cgit v1.3