From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/CodeGenCXX/mangle.cpp | 854 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 854 insertions(+) create mode 100644 clang/test/CodeGenCXX/mangle.cpp (limited to 'clang/test/CodeGenCXX/mangle.cpp') diff --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp new file mode 100644 index 0000000..ba1b3bf --- /dev/null +++ b/clang/test/CodeGenCXX/mangle.cpp @@ -0,0 +1,854 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -fblocks -std=c++11 | FileCheck %s +struct X { }; +struct Y { }; + +// CHECK: @unmangled_variable = global +// CHECK: @_ZN1N1iE = global +// CHECK: @_ZZN1N1fEiiE1b = internal global +// CHECK: @_ZZN1N1gEvE1a = internal global +// CHECK: @_ZGVZN1N1gEvE1a = internal global + +//CHECK: @pr5966_i = external global +//CHECK: @_ZL8pr5966_i = internal global + +// CHECK: define zeroext i1 @_ZplRK1YRA100_P1X +bool operator+(const Y&, X* (&xs)[100]) { return false; } + +// CHECK: define void @_Z1f1s +typedef struct { int a; } s; +void f(s) { } + +// CHECK: define void @_Z1f1e +typedef enum { foo } e; +void f(e) { } + +// CHECK: define void @_Z1f1u +typedef union { int a; } u; +void f(u) { } + +// CHECK: define void @_Z1f1x +typedef struct { int a; } x,y; +void f(y) { } + +// CHECK: define void @_Z1fv +void f() { } + +// CHECK: define void @_ZN1N1fEv +namespace N { void f() { } } + +// CHECK: define void @_ZN1N1N1fEv +namespace N { namespace N { void f() { } } } + +// CHECK: define void @unmangled_function +extern "C" { namespace N { void unmangled_function() { } } } + +extern "C" { namespace N { int unmangled_variable = 10; } } + +namespace N { int i; } + +namespace N { int f(int, int) { static int b; return b; } } + +namespace N { int h(); void g() { static int a = h(); } } + +// CHECK: define void @_Z1fno +void f(__int128_t, __uint128_t) { } + +template struct S1 {}; + +// CHECK: define void @_Z1f2S1IiE +void f(S1) {} + +// CHECK: define void @_Z1f2S1IdE +void f(S1) {} + +template struct S2 {}; +// CHECK: define void @_Z1f2S2ILi100EE +void f(S2<100>) {} + +// CHECK: define void @_Z1f2S2ILin100EE +void f(S2<-100>) {} + +template struct S3 {}; + +// CHECK: define void @_Z1f2S3ILb1EE +void f(S3) {} + +// CHECK: define void @_Z1f2S3ILb0EE +void f(S3) {} + +struct S; + +// CHECK: define void @_Z1fM1SKFvvE +void f(void (S::*)() const) {} + +// CHECK: define void @_Z1fM1SFvvE +void f(void (S::*)()) {} + +// CHECK: define void @_Z1fi +void f(const int) { } + +template void ft1(U u, T t) { } + +template void ft2(T t, void (*)(T), void (*)(T)) { } + +template > struct S4 { }; +template void ft3(S4*) { } + +namespace NS { + template void ft1(T) { } +} + +void g1() { + // CHECK: @_Z3ft1IidEvT0_T_ + ft1(1, 0); + + // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_ + ft2(1, 0, 0); + + // CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE + ft3(0); + + // CHECK: @_ZN2NS3ft1IiEEvT_ + NS::ft1(1); +} + +// Expressions +template struct S5 { }; + +template void ft4(S5) { } +void g2() { + // CHECK: @_Z3ft4ILi10EEv2S5IXT_EE + ft4(S5<10>()); + + // CHECK: @_Z3ft4ILi20EEv2S5IXT_EE + ft4(S5<20>()); +} + +extern "C++" { + // CHECK: @_Z1hv + void h() { } +} + +// PR5019 +extern "C" { struct a { int b; }; } + +// CHECK: @_Z1fP1a +int f(struct a *x) { + return x->b; +} + +// PR5017 +extern "C" { +struct Debug { + const Debug& operator<< (unsigned a) const { return *this; } +}; +Debug dbg; +// CHECK: @_ZNK5DebuglsEj +int main(void) { dbg << 32 ;} +} + +template struct S6 { + typedef int B; +}; + +template void ft5(typename S6::B) { } +// CHECK: @_Z3ft5IiEvN2S6IT_E1BE +template void ft5(int); + +template class A {}; + +namespace NS { +template bool operator==(const A&, const A&) { return true; } +} + +// CHECK: @_ZN2NSeqIcEEbRK1AIT_ES5_ +template bool NS::operator==(const ::A&, const ::A&); + +namespace std { +template bool operator==(const A&, const A&) { return true; } +} + +// CHECK: @_ZSteqIcEbRK1AIT_ES4_ +template bool std::operator==(const ::A&, const ::A&); + +struct S { + typedef int U; +}; + +template typename T::U ft6(const T&) { return 0; } + +// CHECK: @_Z3ft6I1SENT_1UERKS1_ +template int ft6(const S&); + +template struct __is_scalar_type { + enum { __value = 1 }; +}; + +template struct __enable_if { }; + +template struct __enable_if { + typedef T __type; +}; + +// PR5063 +template typename __enable_if<__is_scalar_type::__value, void>::__type ft7() { } + +// CHECK: @_Z3ft7IiEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv +template void ft7(); +// CHECK: @_Z3ft7IPvEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv +template void ft7(); + +// PR5144 +extern "C" { +void extern_f(void); +}; + +// CHECK: @extern_f +void extern_f(void) { } + +struct S7 { + S7(); + + struct S { S(); }; + struct { + S s; + } a; +}; + +// PR5139 +// CHECK: @_ZN2S7C1Ev +// CHECK: @_ZN2S7C2Ev +// CHECK: @"_ZN2S73$_0C1Ev" +S7::S7() {} + +// PR5063 +template typename __enable_if<(__is_scalar_type::__value), void>::__type ft8() { } +// CHECK: @_Z3ft8IiEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv +template void ft8(); +// CHECK: @_Z3ft8IPvEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv +template void ft8(); + +// PR5796 +namespace PR5796 { +template struct __is_scalar_type { + enum { __value = 0 }; +}; + +template struct __enable_if {}; +template struct __enable_if { typedef T __type; }; +template + +// CHECK: define linkonce_odr void @_ZN6PR57968__fill_aIiEENS_11__enable_ifIXntsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv +typename __enable_if::__value, void>::__type __fill_a() { }; + +void f() { __fill_a(); } +} + +namespace Expressions { +// Unary operators. + +// CHECK: define weak_odr void @_ZN11Expressions2f1ILi1EEEvPAplngT_Li2E_i +template void f1(int (*)[(-i) + 2]) { }; +template void f1<1>(int (*)[1]); + +// CHECK: define weak_odr void @_ZN11Expressions2f2ILi1EEEvPApsT__i +template void f2(int (*)[+i]) { }; +template void f2<1>(int (*)[1]); + +// Binary operators. + +// CHECK: define weak_odr void @_ZN11Expressions2f3ILi1EEEvPAplT_T__i +template void f3(int (*)[i+i]) { }; +template void f3<1>(int (*)[2]); + +// CHECK: define weak_odr void @_ZN11Expressions2f4ILi1EEEvPAplplLi2ET_T__i +template void f4(int (*)[2 + i+i]) { }; +template void f4<1>(int (*)[4]); + +// The ternary operator. +// CHECK: define weak_odr void @_ZN11Expressions2f4ILb1EEEvPAquT_Li1ELi2E_i +template void f4(int (*)[b ? 1 : 2]) { }; +template void f4(int (*)[1]); +} + +struct Ops { + Ops& operator+(const Ops&); + Ops& operator-(const Ops&); + Ops& operator&(const Ops&); + Ops& operator*(const Ops&); + + void *v; +}; + +// CHECK: define %struct.Ops* @_ZN3OpsplERKS_ +Ops& Ops::operator+(const Ops&) { return *this; } +// CHECK: define %struct.Ops* @_ZN3OpsmiERKS_ +Ops& Ops::operator-(const Ops&) { return *this; } +// CHECK: define %struct.Ops* @_ZN3OpsanERKS_ +Ops& Ops::operator&(const Ops&) { return *this; } +// CHECK: define %struct.Ops* @_ZN3OpsmlERKS_ +Ops& Ops::operator*(const Ops&) { return *this; } + +// PR5861 +namespace PR5861 { +template class P; +template<> class P {}; + +template