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