1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s 2 3 // Check mangling of Vtables, VTTs, and construction vtables that 4 // involve standard substitutions. 5 6 // CHECK: @_ZTTSd = linkonce_odr unnamed_addr constant 7 // CHECK: @_ZTVSd = linkonce_odr unnamed_addr constant 8 // CHECK: @_ZTCSd0_Si = linkonce_odr unnamed_addr constant 9 // CHECK: @_ZTCSd16_So = linkonce_odr unnamed_addr constant 10 // CHECK: @_ZTTSo = linkonce_odr unnamed_addr constant 11 // CHECK: @_ZTVSo = linkonce_odr unnamed_addr constant 12 // CHECK: @_ZTTSi = linkonce_odr unnamed_addr constant 13 // CHECK: @_ZTVSi = linkonce_odr unnamed_addr constant 14 namespace std { 15 struct A { A(); }; 16 17 // CHECK: define void @_ZNSt1AC1Ev(%"struct.N::std::A"* %this) unnamed_addr 18 // CHECK: define void @_ZNSt1AC2Ev(%"struct.N::std::A"* %this) unnamed_addr 19 A::A() { } 20 }; 21 22 namespace std { 23 template<typename> struct allocator { }; 24 } 25 26 // CHECK: define void @_Z1fSaIcESaIiE 27 void f(std::allocator<char>, std::allocator<int>) { } 28 29 namespace std { 30 template<typename, typename, typename> struct basic_string { }; 31 } 32 33 // CHECK: define void @_Z1fSbIcciE 34 void f(std::basic_string<char, char, int>) { } 35 36 namespace std { 37 template<typename> struct char_traits { }; 38 39 typedef std::basic_string<char, std::char_traits<char>, std::allocator<char> > string; 40 } 41 42 // CHECK: _Z1fSs 43 void f(std::string) { } 44 45 namespace std { 46 template<typename, typename> struct basic_ios { 47 basic_ios(int); 48 virtual ~basic_ios(); 49 }; 50 template<typename charT, typename traits = char_traits<charT> > 51 struct basic_istream : virtual public basic_ios<charT, traits> { 52 basic_istream(int x) : basic_ios<charT, traits>(x), stored(x) { } 53 54 int stored; 55 }; 56 template<typename charT, typename traits = char_traits<charT> > 57 struct basic_ostream : virtual public basic_ios<charT, traits> { 58 basic_ostream(int x) : basic_ios<charT, traits>(x), stored(x) { } 59 60 float stored; 61 }; 62 63 template<typename charT, typename traits = char_traits<charT> > 64 struct basic_iostream : public basic_istream<charT, traits>, 65 public basic_ostream<charT, traits> { 66 basic_iostream(int x) : basic_istream<charT, traits>(x), 67 basic_ostream<charT, traits>(x), 68 basic_ios<charT, traits>(x) { } 69 }; 70 } 71 72 // CHECK: _Z1fSi 73 void f(std::basic_istream<char, std::char_traits<char> >) { } 74 75 // CHECK: _Z1fSo 76 void f(std::basic_ostream<char, std::char_traits<char> >) { } 77 78 // CHECK: _Z1fSd 79 void f(std::basic_iostream<char, std::char_traits<char> >) { } 80 81 extern "C++" { 82 namespace std 83 { 84 typedef void (*terminate_handler) (); 85 86 // CHECK: _ZSt13set_terminatePFvvE 87 terminate_handler set_terminate(terminate_handler) { return 0; } 88 } 89 } 90 91 // Make sure we don't treat the following like std::string 92 // CHECK: define void @_Z1f12basic_stringIcSt11char_traitsIcESaIcEE 93 template<typename, typename, typename> struct basic_string { }; 94 typedef basic_string<char, std::char_traits<char>, std::allocator<char> > not_string; 95 void f(not_string) { } 96 97 // Manglings for instantiations caused by this function are at the 98 // top of the test. 99 void create_streams() { 100 std::basic_iostream<char> bio(17); 101 } 102 103 // Make sure we don't mangle 'std' as 'St' here. 104 namespace N { 105 namespace std { 106 struct A { void f(); }; 107 108 // CHECK: define void @_ZN1N3std1A1fEv 109 void A::f() { } 110 } 111 } 112