Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Richard Smith | 0b87e07 | 2013-10-07 08:02:11 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs -verify %s -Wno-objc-root-class |
| 3 | // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class | FileCheck %s |
Andy Gibbs | c6e68da | 2012-10-19 12:44:48 +0000 | [diff] [blame] | 4 | // expected-no-diagnostics |
Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 5 | |
Douglas Gregor | c50d492 | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 6 | @import templates_left; |
Richard Smith | 195d8ef | 2014-05-29 03:15:31 +0000 | [diff] [blame] | 7 | |
| 8 | void testInlineRedeclEarly() { |
| 9 | // instantiate definition now, we'll add another declaration in _right. |
| 10 | OutOfLineInline<int>().h(); |
| 11 | } |
| 12 | |
Douglas Gregor | c50d492 | 2012-12-11 22:11:52 +0000 | [diff] [blame] | 13 | @import templates_right; |
Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 14 | |
Richard Smith | 0b87e07 | 2013-10-07 08:02:11 +0000 | [diff] [blame] | 15 | // CHECK: @list_left = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 8, |
| 16 | // CHECK: @list_right = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 12, |
| 17 | // CHECK: @_ZZ15testMixedStructvE1l = {{.*}} constant { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 1, |
| 18 | // CHECK: @_ZZ15testMixedStructvE1r = {{.*}} constant { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 2, |
Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 19 | |
| 20 | void testTemplateClasses() { |
| 21 | Vector<int> vec_int; |
| 22 | vec_int.push_back(0); |
| 23 | |
| 24 | List<bool> list_bool; |
| 25 | list_bool.push_back(false); |
| 26 | |
| 27 | N::Set<char> set_char; |
| 28 | set_char.insert('A'); |
Richard Smith | cd45dbc | 2014-04-19 03:48:30 +0000 | [diff] [blame] | 29 | |
| 30 | List<double> list_double; |
| 31 | list_double.push_back(0.0); |
Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | void testPendingInstantiations() { |
Axel Naumann | d9a25b3 | 2012-10-02 12:18:46 +0000 | [diff] [blame] | 35 | // CHECK: call {{.*pendingInstantiationEmit}} |
| 36 | // CHECK: call {{.*pendingInstantiationEmit}} |
| 37 | // CHECK: define {{.*pendingInstantiationEmit.*[(]i}} |
| 38 | // CHECK: define {{.*pendingInstantiationEmit.*[(]double}} |
Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 39 | triggerPendingInstantiation(); |
| 40 | triggerPendingInstantiationToo(); |
| 41 | } |
Axel Naumann | d9a25b3 | 2012-10-02 12:18:46 +0000 | [diff] [blame] | 42 | |
| 43 | void testRedeclDefinition() { |
| 44 | // CHECK: define {{.*redeclDefinitionEmit}} |
| 45 | redeclDefinitionEmit(); |
| 46 | } |
| 47 | |
Richard Smith | 195d8ef | 2014-05-29 03:15:31 +0000 | [diff] [blame] | 48 | void testInlineRedecl() { |
| 49 | outOfLineInlineUseLeftF(); |
| 50 | outOfLineInlineUseRightG(); |
| 51 | |
| 52 | outOfLineInlineUseRightF(); |
| 53 | outOfLineInlineUseLeftG(); |
| 54 | } |
| 55 | |
Richard Smith | eb36ddf | 2014-04-24 22:45:46 +0000 | [diff] [blame] | 56 | // CHECK-NOT: @_ZN21ExplicitInstantiationILb0ELb0EE1fEv( |
| 57 | // CHECK: declare {{.*}}@_ZN21ExplicitInstantiationILb1ELb0EE1fEv( |
| 58 | // CHECK: define {{.*}}@_ZN21ExplicitInstantiationILb1ELb1EE1fEv( |
| 59 | // CHECK-NOT: @_ZN21ExplicitInstantiationILb0ELb0EE1fEv( |
| 60 | |
Richard Smith | d55889a | 2013-09-09 16:55:27 +0000 | [diff] [blame] | 61 | // These three are all the same type. |
| 62 | typedef OuterIntInner_left OuterIntInner; |
| 63 | typedef OuterIntInner_right OuterIntInner; |
| 64 | typedef Outer<int>::Inner OuterIntInner; |
| 65 | |
Axel Naumann | d9a25b3 | 2012-10-02 12:18:46 +0000 | [diff] [blame] | 66 | // CHECK: call {{.*pendingInstantiation}} |
| 67 | // CHECK: call {{.*redeclDefinitionEmit}} |
Richard Smith | 0b87e07 | 2013-10-07 08:02:11 +0000 | [diff] [blame] | 68 | |
| 69 | static_assert(size_left == size_right, "same field both ways"); |
| 70 | void useListInt(List<int> &); |
| 71 | |
| 72 | // CHECK-LABEL: define i32 @_Z15testMixedStructv( |
| 73 | unsigned testMixedStruct() { |
| 74 | // CHECK: %[[l:.*]] = alloca %[[ListInt:[^ ]*]], align 8 |
| 75 | // CHECK: %[[r:.*]] = alloca %[[ListInt]], align 8 |
| 76 | |
| 77 | // CHECK: call {{.*}}memcpy{{.*}}(i8* %{{.*}}, i8* bitcast ({{.*}}* @_ZZ15testMixedStructvE1l to i8*), i64 16, |
| 78 | ListInt_left l{0, 1}; |
| 79 | |
| 80 | // CHECK: call {{.*}}memcpy{{.*}}(i8* %{{.*}}, i8* bitcast ({{.*}}* @_ZZ15testMixedStructvE1r to i8*), i64 16, |
| 81 | ListInt_right r{0, 2}; |
| 82 | |
Hal Finkel | a2347ba | 2014-07-18 15:52:10 +0000 | [diff] [blame^] | 83 | // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[l]]) |
Richard Smith | 0b87e07 | 2013-10-07 08:02:11 +0000 | [diff] [blame] | 84 | useListInt(l); |
Hal Finkel | a2347ba | 2014-07-18 15:52:10 +0000 | [diff] [blame^] | 85 | // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[r]]) |
Richard Smith | 0b87e07 | 2013-10-07 08:02:11 +0000 | [diff] [blame] | 86 | useListInt(r); |
| 87 | |
| 88 | // CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_left to i8*), i64 8) to i32*) |
| 89 | // CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_right to i8*), i64 8) to i32*) |
| 90 | return list_left.*size_right + list_right.*size_left; |
| 91 | } |
Richard Smith | f17fdbd | 2014-04-24 02:25:27 +0000 | [diff] [blame] | 92 | |
| 93 | template<typename T> struct MergePatternDecl { |
| 94 | typedef int Type; |
| 95 | void f(Type); |
| 96 | }; |
| 97 | template<typename T> void MergePatternDecl<T>::f(Type type) {} |
Richard Smith | eb36ddf | 2014-04-24 22:45:46 +0000 | [diff] [blame] | 98 | // CHECK: define {{.*}}@_ZN21ExplicitInstantiationILb0ELb1EE1fEv( |
| 99 | template struct ExplicitInstantiation<false, true>; |
| 100 | template struct ExplicitInstantiation<true, true>; |
Richard Smith | d1c4674 | 2014-04-30 02:24:17 +0000 | [diff] [blame] | 101 | |
| 102 | void testDelayUpdatesImpl() { testDelayUpdates<int>(); } |