summaryrefslogtreecommitdiff
path: root/test/CodeGenCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGenCXX')
-rw-r--r--test/CodeGenCXX/block-byref-cxx-objc.cpp10
-rw-r--r--test/CodeGenCXX/const-init-cxx11.cpp3
-rw-r--r--test/CodeGenCXX/cxx11-exception-spec.cpp120
-rw-r--r--test/CodeGenCXX/inheriting-constructor.cpp2
-rw-r--r--test/CodeGenCXX/mangle-this-cxx11.cpp20
-rw-r--r--test/CodeGenCXX/static-init.cpp2
6 files changed, 157 insertions, 0 deletions
diff --git a/test/CodeGenCXX/block-byref-cxx-objc.cpp b/test/CodeGenCXX/block-byref-cxx-objc.cpp
index 135e0c7551942..30f1f074b9b36 100644
--- a/test/CodeGenCXX/block-byref-cxx-objc.cpp
+++ b/test/CodeGenCXX/block-byref-cxx-objc.cpp
@@ -23,3 +23,13 @@ int main()
// CHECK: call void @_Block_object_assign
// CHECK: define internal void @__destroy_helper_block_
// CHECK: call void @_Block_object_dispose
+
+// rdar://problem/11135650
+namespace test1 {
+ struct A { int x; A(); ~A(); };
+
+ void test() {
+ return;
+ __block A a;
+ }
+}
diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp
index c745deebf04b5..62a345a495645 100644
--- a/test/CodeGenCXX/const-init-cxx11.cpp
+++ b/test/CodeGenCXX/const-init-cxx11.cpp
@@ -92,6 +92,9 @@ namespace Array {
// CHECK: @_ZN5Array1cE = constant [6 x [4 x i8]] [{{.*}} c"foo\00", [4 x i8] c"a\00\00\00", [4 x i8] c"bar\00", [4 x i8] c"xyz\00", [4 x i8] c"b\00\00\00", [4 x i8] c"123\00"]
extern constexpr char c[6][4] = { "foo", "a", { "bar" }, { 'x', 'y', 'z' }, { "b" }, '1', '2', '3' };
+ // CHECK: @_ZN5Array2ucE = constant [4 x i8] c"foo\00"
+ extern constexpr unsigned char uc[] = { "foo" };
+
struct C { constexpr C() : n(5) {} int n, m = 3 * n + 1; };
// CHECK: @_ZN5Array5ctorsE = constant [3 x {{.*}}] [{{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }]
extern const C ctors[3];
diff --git a/test/CodeGenCXX/cxx11-exception-spec.cpp b/test/CodeGenCXX/cxx11-exception-spec.cpp
new file mode 100644
index 0000000000000..194b80cdd47e8
--- /dev/null
+++ b/test/CodeGenCXX/cxx11-exception-spec.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s
+
+void h();
+
+template<typename T> void f() noexcept(sizeof(T) == 4) { h(); }
+template<typename T> void g() noexcept(sizeof(T) == 4);
+
+template<typename T> struct S {
+ static void f() noexcept(sizeof(T) == 4) { h(); }
+ static void g() noexcept(sizeof(T) == 4);
+};
+
+// CHECK: define {{.*}} @_Z1fIsEvv() {
+template<> void f<short>() { h(); }
+// CHECK: define {{.*}} @_Z1fIA2_sEvv() nounwind {
+template<> void f<short[2]>() noexcept { h(); }
+
+// CHECK: define {{.*}} @_ZN1SIsE1fEv()
+// CHECK-NOT: nounwind
+template<> void S<short>::f() { h(); }
+// CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() nounwind
+template<> void S<short[2]>::f() noexcept { h(); }
+
+// CHECK: define {{.*}} @_Z1fIDsEvv() {
+template void f<char16_t>();
+// CHECK: define {{.*}} @_Z1fIA2_DsEvv() nounwind {
+template void f<char16_t[2]>();
+
+// CHECK: define {{.*}} @_ZN1SIDsE1fEv()
+// CHECK-NOT: nounwind
+template void S<char16_t>::f();
+// CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() nounwind
+template void S<char16_t[2]>::f();
+
+void h() {
+ // CHECK: define {{.*}} @_Z1fIiEvv() nounwind {
+ f<int>();
+ // CHECK: define {{.*}} @_Z1fIA2_iEvv() {
+ f<int[2]>();
+
+ // CHECK: define {{.*}} @_ZN1SIiE1fEv() nounwind
+ S<int>::f();
+ // CHECK: define {{.*}} @_ZN1SIA2_iE1fEv()
+ // CHECK-NOT: nounwind
+ S<int[2]>::f();
+
+ // CHECK: define {{.*}} @_Z1fIfEvv() nounwind {
+ void (*f1)() = &f<float>;
+ // CHECK: define {{.*}} @_Z1fIdEvv() {
+ void (*f2)() = &f<double>;
+
+ // CHECK: define {{.*}} @_ZN1SIfE1fEv() nounwind
+ void (*f3)() = &S<float>::f;
+ // CHECK: define {{.*}} @_ZN1SIdE1fEv()
+ // CHECK-NOT: nounwind
+ void (*f4)() = &S<double>::f;
+
+ // CHECK: define {{.*}} @_Z1fIA4_cEvv() nounwind {
+ (void)&f<char[4]>;
+ // CHECK: define {{.*}} @_Z1fIcEvv() {
+ (void)&f<char>;
+
+ // CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() nounwind
+ (void)&S<char[4]>::f;
+ // CHECK: define {{.*}} @_ZN1SIcE1fEv()
+ // CHECK-NOT: nounwind
+ (void)&S<char>::f;
+}
+
+// CHECK: define {{.*}} @_Z1iv
+void i() {
+ // CHECK: declare {{.*}} @_Z1gIiEvv() nounwind
+ g<int>();
+ // CHECK: declare {{.*}} @_Z1gIA2_iEvv()
+ // CHECK-NOT: nounwind
+ g<int[2]>();
+
+ // CHECK: declare {{.*}} @_ZN1SIiE1gEv() nounwind
+ S<int>::g();
+ // CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv()
+ // CHECK-NOT: nounwind
+ S<int[2]>::g();
+
+ // CHECK: declare {{.*}} @_Z1gIfEvv() nounwind
+ void (*g1)() = &g<float>;
+ // CHECK: declare {{.*}} @_Z1gIdEvv()
+ // CHECK-NOT: nounwind
+ void (*g2)() = &g<double>;
+
+ // CHECK: declare {{.*}} @_ZN1SIfE1gEv() nounwind
+ void (*g3)() = &S<float>::g;
+ // CHECK: declare {{.*}} @_ZN1SIdE1gEv()
+ // CHECK-NOT: nounwind
+ void (*g4)() = &S<double>::g;
+
+ // CHECK: declare {{.*}} @_Z1gIA4_cEvv() nounwind
+ (void)&g<char[4]>;
+ // CHECK: declare {{.*}} @_Z1gIcEvv()
+ // CHECK-NOT: nounwind
+ (void)&g<char>;
+
+ // CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() nounwind
+ (void)&S<char[4]>::g;
+ // CHECK: declare {{.*}} @_ZN1SIcE1gEv()
+ // CHECK-NOT: nounwind
+ (void)&S<char>::g;
+}
+
+template<typename T> struct Nested {
+ template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U));
+};
+
+// CHECK: define {{.*}} @_Z1jv
+void j() {
+ // CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv(
+ // CHECK-NOT: nounwind
+ Nested<int>().f<true, char>();
+ // CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) nounwind
+ Nested<long>().f<false, long>();
+}
diff --git a/test/CodeGenCXX/inheriting-constructor.cpp b/test/CodeGenCXX/inheriting-constructor.cpp
index b921a6d2bb930..a99840290a550 100644
--- a/test/CodeGenCXX/inheriting-constructor.cpp
+++ b/test/CodeGenCXX/inheriting-constructor.cpp
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// XFAIL: *
+
// PR12219
struct A { A(int); virtual ~A(); };
struct B : A { using A::A; ~B(); };
diff --git a/test/CodeGenCXX/mangle-this-cxx11.cpp b/test/CodeGenCXX/mangle-this-cxx11.cpp
new file mode 100644
index 0000000000000..f9e94797b1596
--- /dev/null
+++ b/test/CodeGenCXX/mangle-this-cxx11.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+struct B {
+ template <class U> U f();
+};
+
+struct A {
+ B b;
+ // implicitly rewritten to (*this).b.f<U>()
+ template <class U> auto f() -> decltype (b.f<U>());
+ template <class U> auto g() -> decltype (this->b.f<U>());
+};
+
+int main() {
+ A a;
+ // CHECK: call i32 @_ZN1A1fIiEEDTcldtdtdefpT1b1fIT_EEEv
+ a.f<int>();
+ // CHECK: call i32 @_ZN1A1gIiEEDTcldtptfpT1b1fIT_EEEv
+ a.g<int>();
+}
diff --git a/test/CodeGenCXX/static-init.cpp b/test/CodeGenCXX/static-init.cpp
index ed659de5e0624..74278f7128c88 100644
--- a/test/CodeGenCXX/static-init.cpp
+++ b/test/CodeGenCXX/static-init.cpp
@@ -2,6 +2,7 @@
// CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
// CHECK: @base_req = global [4 x i8] c"foo\00", align 1
+// CHECK: @base_req_uchar = global [4 x i8] c"bar\00", align 1
// CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4
// CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
@@ -64,6 +65,7 @@ namespace test1 {
// Make sure we emit the initializer correctly for the following:
char base_req[] = { "foo" };
+unsigned char base_req_uchar[] = { "bar" };
namespace union_static_local {
// CHECK: define internal void @_ZZN18union_static_local4testEvEN1c4mainEv