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; |
| 7 | @import templates_right; |
Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 8 | |
Richard Smith | 0b87e07 | 2013-10-07 08:02:11 +0000 | [diff] [blame^] | 9 | // CHECK: @list_left = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 8, |
| 10 | // CHECK: @list_right = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 12, |
| 11 | // CHECK: @_ZZ15testMixedStructvE1l = {{.*}} constant { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 1, |
| 12 | // CHECK: @_ZZ15testMixedStructvE1r = {{.*}} constant { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 2, |
Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 13 | |
| 14 | void testTemplateClasses() { |
| 15 | Vector<int> vec_int; |
| 16 | vec_int.push_back(0); |
| 17 | |
| 18 | List<bool> list_bool; |
| 19 | list_bool.push_back(false); |
| 20 | |
| 21 | N::Set<char> set_char; |
| 22 | set_char.insert('A'); |
| 23 | } |
| 24 | |
| 25 | void testPendingInstantiations() { |
Axel Naumann | d9a25b3 | 2012-10-02 12:18:46 +0000 | [diff] [blame] | 26 | // CHECK: call {{.*pendingInstantiationEmit}} |
| 27 | // CHECK: call {{.*pendingInstantiationEmit}} |
| 28 | // CHECK: define {{.*pendingInstantiationEmit.*[(]i}} |
| 29 | // CHECK: define {{.*pendingInstantiationEmit.*[(]double}} |
Axel Naumann | 63469422c | 2012-10-02 09:09:43 +0000 | [diff] [blame] | 30 | triggerPendingInstantiation(); |
| 31 | triggerPendingInstantiationToo(); |
| 32 | } |
Axel Naumann | d9a25b3 | 2012-10-02 12:18:46 +0000 | [diff] [blame] | 33 | |
| 34 | void testRedeclDefinition() { |
| 35 | // CHECK: define {{.*redeclDefinitionEmit}} |
| 36 | redeclDefinitionEmit(); |
| 37 | } |
| 38 | |
Richard Smith | d55889a | 2013-09-09 16:55:27 +0000 | [diff] [blame] | 39 | // These three are all the same type. |
| 40 | typedef OuterIntInner_left OuterIntInner; |
| 41 | typedef OuterIntInner_right OuterIntInner; |
| 42 | typedef Outer<int>::Inner OuterIntInner; |
| 43 | |
Axel Naumann | d9a25b3 | 2012-10-02 12:18:46 +0000 | [diff] [blame] | 44 | // CHECK: call {{.*pendingInstantiation}} |
| 45 | // CHECK: call {{.*redeclDefinitionEmit}} |
Richard Smith | 0b87e07 | 2013-10-07 08:02:11 +0000 | [diff] [blame^] | 46 | |
| 47 | static_assert(size_left == size_right, "same field both ways"); |
| 48 | void useListInt(List<int> &); |
| 49 | |
| 50 | // CHECK-LABEL: define i32 @_Z15testMixedStructv( |
| 51 | unsigned testMixedStruct() { |
| 52 | // CHECK: %[[l:.*]] = alloca %[[ListInt:[^ ]*]], align 8 |
| 53 | // CHECK: %[[r:.*]] = alloca %[[ListInt]], align 8 |
| 54 | |
| 55 | // CHECK: call {{.*}}memcpy{{.*}}(i8* %{{.*}}, i8* bitcast ({{.*}}* @_ZZ15testMixedStructvE1l to i8*), i64 16, |
| 56 | ListInt_left l{0, 1}; |
| 57 | |
| 58 | // CHECK: call {{.*}}memcpy{{.*}}(i8* %{{.*}}, i8* bitcast ({{.*}}* @_ZZ15testMixedStructvE1r to i8*), i64 16, |
| 59 | ListInt_right r{0, 2}; |
| 60 | |
| 61 | // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* %[[l]]) |
| 62 | useListInt(l); |
| 63 | // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* %[[r]]) |
| 64 | useListInt(r); |
| 65 | |
| 66 | // CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_left to i8*), i64 8) to i32*) |
| 67 | // CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_right to i8*), i64 8) to i32*) |
| 68 | return list_left.*size_right + list_right.*size_left; |
| 69 | } |