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