summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/mangle.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2011-07-17 15:40:56 +0000
committerdim <dim@FreeBSD.org>2011-07-17 15:40:56 +0000
commit611ba3ea3300b71eb95dc4e45f20eee5dddd32e1 (patch)
tree2097d084eb235c0b12c0bff3445f4ec7bbaa8a12 /test/CodeGenCXX/mangle.cpp
parentc49018d9cce52d8c9f34b44865ec3ba8e89a1488 (diff)
downloadFreeBSD-src-611ba3ea3300b71eb95dc4e45f20eee5dddd32e1.zip
FreeBSD-src-611ba3ea3300b71eb95dc4e45f20eee5dddd32e1.tar.gz
Vendor import of clang trunk r135360:
http://llvm.org/svn/llvm-project/cfe/trunk@135360
Diffstat (limited to 'test/CodeGenCXX/mangle.cpp')
-rw-r--r--test/CodeGenCXX/mangle.cpp157
1 files changed, 152 insertions, 5 deletions
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 01dcf8b..453b7b7 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -196,9 +196,9 @@ template<typename T> struct __enable_if<true, T> {
// PR5063
template<typename T> typename __enable_if<__is_scalar_type<T>::__value, void>::__type ft7() { }
-// CHECK: @_Z3ft7IiEN11__enable_ifIXsr16__is_scalar_typeIT_E7__valueEvE6__typeEv
+// CHECK: @_Z3ft7IiEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
template void ft7<int>();
-// CHECK: @_Z3ft7IPvEN11__enable_ifIXsr16__is_scalar_typeIT_E7__valueEvE6__typeEv
+// CHECK: @_Z3ft7IPvEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
template void ft7<void*>();
// PR5144
@@ -226,9 +226,9 @@ S7::S7() {}
// PR5063
template<typename T> typename __enable_if<(__is_scalar_type<T>::__value), void>::__type ft8() { }
-// CHECK: @_Z3ft8IiEN11__enable_ifIXsr16__is_scalar_typeIT_E7__valueEvE6__typeEv
+// CHECK: @_Z3ft8IiEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
template void ft8<int>();
-// CHECK: @_Z3ft8IPvEN11__enable_ifIXsr16__is_scalar_typeIT_E7__valueEvE6__typeEv
+// CHECK: @_Z3ft8IPvEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
template void ft8<void*>();
// PR5796
@@ -241,7 +241,7 @@ template<bool, typename> struct __enable_if {};
template<typename T> struct __enable_if<true, T> { typedef T __type; };
template<typename T>
-// CHECK: define linkonce_odr void @_ZN6PR57968__fill_aIiEENS_11__enable_ifIXntsrNS_16__is_scalar_typeIT_EE7__valueEvE6__typeEv
+// CHECK: define linkonce_odr void @_ZN6PR57968__fill_aIiEENS_11__enable_ifIXntsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
typename __enable_if<!__is_scalar_type<T>::__value, void>::__type __fill_a() { };
void f() { __fill_a<int>(); }
@@ -711,3 +711,150 @@ namespace test27 {
b<A>(f);
}
}
+
+// An injected class name type in a unresolved-name.
+namespace test28 {
+ template <class T> struct A {
+ enum { bit };
+ };
+
+ template <class T> void foo(decltype(A<T>::A::bit) x);
+
+ void test() {
+ foo<char>(A<char>::bit);
+ // CHECK: call void @_ZN6test283fooIcEEvDtsr1AIT_E1AE3bitE(
+ }
+}
+
+// An enclosing template type parameter in an unresolved-name.
+namespace test29 {
+ template <class T> struct A {
+ template <class U> static void foo(decltype(T::fn(U())) x);
+ };
+ struct B { static int fn(int); static long fn(long); };
+
+ void test() {
+ A<B>::foo<int>(0);
+ // CHECK: call void @_ZN6test291AINS_1BEE3fooIiEEvDTclsrS1_2fncvT__EEE(
+ }
+}
+
+// An enclosing template template parameter in an unresolved-name.
+namespace test30 {
+ template <template <class> class T> struct A {
+ template <class U> static void foo(decltype(T<U>::fn()) x);
+ };
+ template <class T> struct B { static T fn(); };
+
+ void test() {
+ A<B>::foo<int>(0);
+ // CHECK: call void @_ZN6test301AINS_1BEE3fooIiEEvDTclsrS1_IT_EE2fnEE(
+ }
+}
+
+namespace test31 { // instantiation-dependent mangling of decltype
+ int x;
+ template<class T> auto f1(T p)->decltype(x) { return 0; }
+ // The return type in the mangling of the template signature
+ // is encoded as "i".
+ template<class T> auto f2(T p)->decltype(p) { return 0; }
+ // The return type in the mangling of the template signature
+ // is encoded as "Dtfp_E".
+ void g(int);
+ template<class T> auto f3(T p)->decltype(g(p)) {}
+
+ // CHECK: define weak_odr i32 @_ZN6test312f1IiEEiT_(
+ template int f1(int);
+ // CHECK: define weak_odr i32 @_ZN6test312f2IiEEDtfp_ET_
+ template int f2(int);
+ // CHECK: define weak_odr void @_ZN6test312f3IiEEDTcl1gfp_EET_
+ template void f3(int);
+}
+
+// PR10205
+namespace test32 {
+ template<typename T, int=T::value> struct A {
+ typedef int type;
+ };
+ struct B { enum { value = 4 }; };
+
+ template <class T> typename A<T>::type foo() { return 0; }
+ void test() {
+ foo<B>();
+ // CHECK: call i32 @_ZN6test323fooINS_1BEEENS_1AIT_XsrS3_5valueEE4typeEv()
+ }
+}
+
+namespace test33 {
+ template <class T> struct X {
+ enum { value = T::value };
+ };
+
+ template<typename T, int=X<T>::value> struct A {
+ typedef int type;
+ };
+ struct B { enum { value = 4 }; };
+
+ template <class T> typename A<T>::type foo() { return 0; }
+
+ void test() {
+ foo<B>();
+ // CHECK: call i32 @_ZN6test333fooINS_1BEEENS_1AIT_Xsr1XIS3_EE5valueEE4typeEv()
+ }
+}
+
+namespace test34 {
+ // Mangling for instantiation-dependent decltype expressions.
+ template<typename T>
+ void f(decltype(sizeof(decltype(T() + T())))) {}
+
+ // CHECK: define weak_odr void @_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
+ template void f<int>(decltype(sizeof(1)));
+
+ // Mangling for non-instantiation-dependent sizeof expressions.
+ template<unsigned N>
+ void f2(int (&)[N + sizeof(int*)]) {}
+
+ // CHECK: define weak_odr void @_ZN6test342f2ILj4EEEvRAplT_Lm8E_i
+ template void f2<4>(int (&)[4 + sizeof(int*)]);
+
+ // Mangling for non-instantiation-dependent sizeof expressions
+ // involving an implicit conversion of the result of the sizeof.
+ template<unsigned long long N>
+ void f3(int (&)[N + sizeof(int*)]) {}
+
+ // CHECK: define weak_odr void @_ZN6test342f3ILy4EEEvRAplT_Ly8E_i
+ template void f3<4>(int (&)[4 + sizeof(int*)]);
+
+ // Mangling for instantiation-dependent sizeof() expressions as
+ // template arguments.
+ template<unsigned> struct A { };
+
+ template<typename T> void f4(::test34::A<sizeof(sizeof(decltype(T() + T())))>) { }
+
+ // CHECK: define weak_odr void @_ZN6test342f4IiEEvNS_1AIXszstDTplcvT__EcvS2__EEEEE
+ template void f4<int>(A<sizeof(sizeof(int))>);
+}
+
+namespace test35 {
+ // Dependent operator names of unknown arity.
+ struct A {
+ template<typename U> A operator+(U) const;
+ };
+
+ template<typename T>
+ void f1(decltype(sizeof(&T::template operator+<int>))) {}
+
+ // CHECK: define weak_odr void @_ZN6test352f1INS_1AEEEvDTszadsrT_plIiEE
+ template void f1<A>(__SIZE_TYPE__);
+}
+
+namespace test36 {
+ template<unsigned> struct A { };
+
+ template<typename ...Types>
+ auto f1(Types... values) -> A<sizeof...(values)> { }
+
+ // CHECK: define weak_odr {{.*}} @_ZN6test362f1IJifEEENS_1AIXsZfp_EEEDpT_
+ template A<2> f1(int, float);
+}
OpenPOWER on IntegriCloud