diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-20 21:20:51 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-20 21:20:51 +0000 |
| commit | 583e75cce441388bc562fa225d23499261a0091e (patch) | |
| tree | 5944a7c248d4a8c858db45abc3444eb69270a3c8 /test/CodeGenCXX | |
| parent | 7442d6faa2719e4e7d33a7021c406c5a4facd74d (diff) | |
Notes
Diffstat (limited to 'test/CodeGenCXX')
| -rw-r--r-- | test/CodeGenCXX/cxx1z-class-deduction.cpp | 21 | ||||
| -rw-r--r-- | test/CodeGenCXX/debug-info.cpp | 2 | ||||
| -rw-r--r-- | test/CodeGenCXX/ubsan-suppress-checks.cpp | 28 | ||||
| -rw-r--r-- | test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp | 20 | ||||
| -rw-r--r-- | test/CodeGenCXX/windows-itanium-dllexport.cpp | 25 |
5 files changed, 88 insertions, 8 deletions
diff --git a/test/CodeGenCXX/cxx1z-class-deduction.cpp b/test/CodeGenCXX/cxx1z-class-deduction.cpp new file mode 100644 index 000000000000..0761f2129b51 --- /dev/null +++ b/test/CodeGenCXX/cxx1z-class-deduction.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -std=c++1z %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s + +template<typename T> struct A { + A(T = 0); + A(void*); +}; + +template<typename T> A(T*) -> A<long>; +A() -> A<int>; + +// CHECK-LABEL: @_Z1fPi( +void f(int *p) { + // CHECK: @_ZN1AIiEC + A a{}; + + // CHECK: @_ZN1AIlEC + A b = p; + + // CHECK: @_ZN1AIxEC + A c = 123LL; +} diff --git a/test/CodeGenCXX/debug-info.cpp b/test/CodeGenCXX/debug-info.cpp index 9575a5129e3d..2b86150b52b5 100644 --- a/test/CodeGenCXX/debug-info.cpp +++ b/test/CodeGenCXX/debug-info.cpp @@ -21,6 +21,7 @@ // CHECK: ![[INCTYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "incomplete" // CHECK-SAME: DIFlagFwdDecl +// CHECK: ![[EXPR]] = !DIExpression() template<typename T> struct Identity { typedef T Type; @@ -117,7 +118,6 @@ struct foo { // For some reason function arguments ended up down here // CHECK: ![[F]] = !DILocalVariable(name: "f", arg: 1, scope: ![[FUNC]] // CHECK-SAME: type: ![[FOO]] -// CHECK: ![[EXPR]] = !DIExpression(DW_OP_deref) foo func(foo f) { return f; // reference 'f' for now because otherwise we hit another bug } diff --git a/test/CodeGenCXX/ubsan-suppress-checks.cpp b/test/CodeGenCXX/ubsan-suppress-checks.cpp index 8ec94556c136..d0e7b32ef96c 100644 --- a/test/CodeGenCXX/ubsan-suppress-checks.cpp +++ b/test/CodeGenCXX/ubsan-suppress-checks.cpp @@ -2,6 +2,20 @@ // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null | FileCheck %s --check-prefixes=CHECK,NULL // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=alignment,null -DCHECK_LAMBDA | FileCheck %s --check-prefixes=LAMBDA +// CHECK-LABEL: define void @_Z22load_non_null_pointersv +void load_non_null_pointers() { + int var; + var = *&var; + + int arr[1]; + arr[0] = arr[0]; + + char c = "foo"[0]; + + // CHECK-NOT: icmp ne {{.*}}, null, !nosanitize + // CHECK: ret void +} + struct A { int foo; @@ -29,8 +43,7 @@ struct A { }; f(); - // LAMBDA: icmp ne %class.anon* %[[FUNCVAR:.*]], null, !nosanitize - // LAMBDA: %[[LAMBDAINT:[0-9]+]] = ptrtoint %class.anon* %[[FUNCVAR]] to i64, !nosanitize + // LAMBDA: %[[LAMBDAINT:[0-9]+]] = ptrtoint %class.anon* %[[FUNCVAR:.*]] to i64, !nosanitize // LAMBDA: and i64 %[[LAMBDAINT]], 7, !nosanitize // LAMBDA: call void @__ubsan_handle_type_mismatch @@ -127,8 +140,8 @@ struct A { struct B { operator A*() const { return nullptr; } - // CHECK-LABEL: define linkonce_odr i32 @_ZN1B11load_memberEv - static int load_member() { + // CHECK-LABEL: define linkonce_odr i32 @_ZN1B11load_memberEPS_ + static int load_member(B *bp) { // Check &b before converting it to an A*. // CHECK: call void @__ubsan_handle_type_mismatch // @@ -136,8 +149,7 @@ struct B { // NULL: call void @__ubsan_handle_type_mismatch // // CHECK-NOT: call void @__ubsan_handle_type_mismatch - B b; - return static_cast<A *>(b)->load_member(); + return static_cast<A *>(*bp)->load_member(); // CHECK: ret i32 } }; @@ -210,7 +222,7 @@ void force_irgen() { A::call_through_reference(*a); A::call_through_pointer(a); - B::load_member(); + B::load_member(nullptr); Base *b = new Derived; b->load_member_1(); @@ -218,4 +230,6 @@ void force_irgen() { Derived *d; d->load_member_2(); d->load_member_3(); + + load_non_null_pointers(); } diff --git a/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp b/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp new file mode 100644 index 000000000000..a23e6a47ab05 --- /dev/null +++ b/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm-only %s -verify + +struct A +{ + int x; + void foo() __unaligned; + void foo(); +}; + +void A::foo() __unaligned +{ + this->x++; +} + +void A::foo() // expected-error {{definition with same mangled name as another definition}} + // expected-note@-6 {{previous definition is here}} +{ + this->x++; +} + diff --git a/test/CodeGenCXX/windows-itanium-dllexport.cpp b/test/CodeGenCXX/windows-itanium-dllexport.cpp index 92cca2444287..ff780c777822 100644 --- a/test/CodeGenCXX/windows-itanium-dllexport.cpp +++ b/test/CodeGenCXX/windows-itanium-dllexport.cpp @@ -1,5 +1,10 @@ // RUN: %clang_cc1 -emit-llvm -triple i686-windows-itanium -fdeclspec %s -o - | FileCheck %s +#define JOIN2(x, y) x##y +#define JOIN(x, y) JOIN2(x, y) +#define UNIQ(name) JOIN(name, __LINE__) +#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; } + struct __declspec(dllexport) s { void f() {} }; @@ -28,3 +33,23 @@ template class __declspec(dllexport) c<double>; // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIdEaSERKS0_ // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIdE1fEv + +template <class T> +struct outer { + void f() {} + struct inner { + void f() {} + }; +}; + +template class __declspec(dllexport) outer<int>; + +// CHECK: define {{.*}} dllexport {{.*}} @_ZN5outerIiE1fEv +// CHECK-NOT: define {{.*}} dllexport {{.*}} @_ZN5outerIiE5inner1fEv + +extern template class __declspec(dllimport) outer<char>; +USEMEMFUNC(outer<char>, f) +USEMEMFUNC(outer<char>::inner, f) + +// CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv +// CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv |
