Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 2 | |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 3 | struct X { }; |
| 4 | struct Y { }; |
Anders Carlsson | b1d947b | 2009-03-07 23:57:03 +0000 | [diff] [blame] | 5 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 6 | // CHECK: @unmangled_variable = global |
| 7 | // CHECK: @_ZN1N1iE = global |
| 8 | // CHECK: @_ZZN1N1fEiiE1b = internal global |
| 9 | // CHECK: @_ZZN1N1gEvE1a = internal global |
| 10 | // CHECK: @_ZGVZN1N1gEvE1a = internal global |
| 11 | |
| 12 | // CHECK: define zeroext i1 @_ZplRK1YRA100_P1X |
Douglas Gregor | 5f2bfd4 | 2009-02-13 00:10:09 +0000 | [diff] [blame] | 13 | bool operator+(const Y&, X* (&xs)[100]) { return false; } |
| 14 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 15 | // CHECK: define void @_Z1f1s |
Anders Carlsson | b1d947b | 2009-03-07 23:57:03 +0000 | [diff] [blame] | 16 | typedef struct { int a; } s; |
| 17 | void f(s) { } |
| 18 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 19 | // CHECK: define void @_Z1f1e |
Anders Carlsson | b1d947b | 2009-03-07 23:57:03 +0000 | [diff] [blame] | 20 | typedef enum { foo } e; |
| 21 | void f(e) { } |
| 22 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 23 | // CHECK: define void @_Z1f1u |
Anders Carlsson | b1d947b | 2009-03-07 23:57:03 +0000 | [diff] [blame] | 24 | typedef union { int a; } u; |
| 25 | void f(u) { } |
Anders Carlsson | 4843e58 | 2009-03-10 17:07:44 +0000 | [diff] [blame] | 26 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 27 | // CHECK: define void @_Z1f1x |
Anders Carlsson | 4843e58 | 2009-03-10 17:07:44 +0000 | [diff] [blame] | 28 | typedef struct { int a; } x,y; |
| 29 | void f(y) { } |
| 30 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 31 | // CHECK: define void @_Z1fv |
Anders Carlsson | c6c91bc | 2009-04-01 00:15:23 +0000 | [diff] [blame] | 32 | void f() { } |
Anders Carlsson | 984e068 | 2009-04-01 00:58:25 +0000 | [diff] [blame] | 33 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 34 | // CHECK: define void @_ZN1N1fEv |
Anders Carlsson | 984e068 | 2009-04-01 00:58:25 +0000 | [diff] [blame] | 35 | namespace N { void f() { } } |
| 36 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 37 | // CHECK: define void @_ZN1N1N1fEv |
Anders Carlsson | 984e068 | 2009-04-01 00:58:25 +0000 | [diff] [blame] | 38 | namespace N { namespace N { void f() { } } } |
Anders Carlsson | 91e20dd | 2009-04-02 05:55:18 +0000 | [diff] [blame] | 39 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 40 | // CHECK: define void @unmangled_function |
Anders Carlsson | 91e20dd | 2009-04-02 05:55:18 +0000 | [diff] [blame] | 41 | extern "C" { namespace N { void unmangled_function() { } } } |
| 42 | |
Anders Carlsson | 2928c21 | 2009-05-16 21:02:39 +0000 | [diff] [blame] | 43 | extern "C" { namespace N { int unmangled_variable = 10; } } |
Anders Carlsson | 91e20dd | 2009-04-02 05:55:18 +0000 | [diff] [blame] | 44 | |
Anders Carlsson | 329749c | 2009-04-02 16:05:20 +0000 | [diff] [blame] | 45 | namespace N { int i; } |
Anders Carlsson | 1b42c79 | 2009-04-02 16:24:45 +0000 | [diff] [blame] | 46 | |
Anders Carlsson | 1b42c79 | 2009-04-02 16:24:45 +0000 | [diff] [blame] | 47 | namespace N { int f(int, int) { static int b; return b; } } |
Anders Carlsson | 283a062 | 2009-04-13 18:03:33 +0000 | [diff] [blame] | 48 | |
Anders Carlsson | 283a062 | 2009-04-13 18:03:33 +0000 | [diff] [blame] | 49 | namespace N { int h(); void g() { static int a = h(); } } |
Chris Lattner | 2df9ced | 2009-04-30 02:43:43 +0000 | [diff] [blame] | 50 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 51 | // CHECK: define void @_Z1fno |
Chris Lattner | 2df9ced | 2009-04-30 02:43:43 +0000 | [diff] [blame] | 52 | void f(__int128_t, __uint128_t) { } |
Anders Carlsson | 7a0ba87 | 2009-05-15 16:09:15 +0000 | [diff] [blame] | 53 | |
| 54 | template <typename T> struct S1 {}; |
| 55 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 56 | // CHECK: define void @_Z1f2S1IiE |
Anders Carlsson | 7a0ba87 | 2009-05-15 16:09:15 +0000 | [diff] [blame] | 57 | void f(S1<int>) {} |
| 58 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 59 | // CHECK: define void @_Z1f2S1IdE |
Anders Carlsson | 7a0ba87 | 2009-05-15 16:09:15 +0000 | [diff] [blame] | 60 | void f(S1<double>) {} |
| 61 | |
| 62 | template <int N> struct S2 {}; |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 63 | // CHECK: define void @_Z1f2S2ILi100EE |
Anders Carlsson | 7a0ba87 | 2009-05-15 16:09:15 +0000 | [diff] [blame] | 64 | void f(S2<100>) {} |
| 65 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 66 | // CHECK: define void @_Z1f2S2ILin100EE |
Anders Carlsson | 7a0ba87 | 2009-05-15 16:09:15 +0000 | [diff] [blame] | 67 | void f(S2<-100>) {} |
| 68 | |
| 69 | template <bool B> struct S3 {}; |
| 70 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 71 | // CHECK: define void @_Z1f2S3ILb1EE |
Anders Carlsson | 7a0ba87 | 2009-05-15 16:09:15 +0000 | [diff] [blame] | 72 | void f(S3<true>) {} |
| 73 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 74 | // CHECK: define void @_Z1f2S3ILb0EE |
Anders Carlsson | 7a0ba87 | 2009-05-15 16:09:15 +0000 | [diff] [blame] | 75 | void f(S3<false>) {} |
| 76 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 77 | // CHECK: define void @_Z2f22S3ILb1EE |
Anders Carlsson | 7a0ba87 | 2009-05-15 16:09:15 +0000 | [diff] [blame] | 78 | void f2(S3<100>) {} |
Anders Carlsson | 0e65001 | 2009-05-17 17:41:20 +0000 | [diff] [blame] | 79 | |
| 80 | struct S; |
| 81 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 82 | // CHECK: define void @_Z1fM1SKFvvE |
Anders Carlsson | 0e65001 | 2009-05-17 17:41:20 +0000 | [diff] [blame] | 83 | void f(void (S::*)() const) {} |
| 84 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 85 | // CHECK: define void @_Z1fM1SFvvE |
Anders Carlsson | 0e65001 | 2009-05-17 17:41:20 +0000 | [diff] [blame] | 86 | void f(void (S::*)()) {} |
Anders Carlsson | cf85b93 | 2009-09-16 23:53:19 +0000 | [diff] [blame] | 87 | |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 88 | // CHECK: define void @_Z1fi |
Anders Carlsson | cf85b93 | 2009-09-16 23:53:19 +0000 | [diff] [blame] | 89 | void f(const int) { } |
| 90 | |
Anders Carlsson | 03c9d53 | 2009-09-17 04:02:31 +0000 | [diff] [blame] | 91 | template<typename T, typename U> void ft1(U u, T t) { } |
| 92 | |
| 93 | template<typename T> void ft2(T t, void (*)(T), void (*)(T)) { } |
Anders Carlsson | 9234b7f | 2009-09-17 03:46:43 +0000 | [diff] [blame] | 94 | |
Anders Carlsson | 7624f21 | 2009-09-18 02:42:01 +0000 | [diff] [blame] | 95 | template<typename T, typename U = S1<T> > struct S4 { }; |
| 96 | template<typename T> void ft3(S4<T>*) { } |
| 97 | |
Anders Carlsson | 7482e24 | 2009-09-18 04:29:09 +0000 | [diff] [blame] | 98 | namespace NS { |
| 99 | template<typename T> void ft1(T) { } |
Anders Carlsson | 7624f21 | 2009-09-18 02:42:01 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Anders Carlsson | d553f8c | 2009-09-21 01:21:10 +0000 | [diff] [blame^] | 102 | void g1() { |
Anders Carlsson | 03c9d53 | 2009-09-17 04:02:31 +0000 | [diff] [blame] | 103 | // CHECK: @_Z3ft1IidEvT0_T_ |
| 104 | ft1<int, double>(1, 0); |
| 105 | |
| 106 | // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_ |
| 107 | ft2<char>(1, 0, 0); |
Anders Carlsson | 7624f21 | 2009-09-18 02:42:01 +0000 | [diff] [blame] | 108 | |
| 109 | // CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE |
| 110 | ft3<int>(0); |
Anders Carlsson | 7482e24 | 2009-09-18 04:29:09 +0000 | [diff] [blame] | 111 | |
| 112 | // CHECK: @_ZN2NS3ft1IiEEvT_ |
| 113 | NS::ft1<int>(1); |
Anders Carlsson | d58d6f7 | 2009-09-17 16:12:20 +0000 | [diff] [blame] | 114 | } |
Anders Carlsson | 7482e24 | 2009-09-18 04:29:09 +0000 | [diff] [blame] | 115 | |
Anders Carlsson | d553f8c | 2009-09-21 01:21:10 +0000 | [diff] [blame^] | 116 | // Expressions |
| 117 | template<int I> struct S5 { }; |
| 118 | |
| 119 | template<int I> void ft4(S5<I>) { } |
| 120 | void g2() { |
| 121 | // CHECK: @_Z3ft4ILi10EEv2S5IXT_EE |
| 122 | ft4(S5<10>()); |
| 123 | |
| 124 | // CHECK: @_Z3ft4ILi20EEv2S5IXT_EE |
| 125 | ft4(S5<20>()); |
| 126 | } |
| 127 | |
Anders Carlsson | 7482e24 | 2009-09-18 04:29:09 +0000 | [diff] [blame] | 128 | extern "C++" { |
| 129 | // CHECK: @_Z1hv |
| 130 | void h() { } |
| 131 | } |
| 132 | |