Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s |
Anders Carlsson | e7c8cb6 | 2009-09-26 20:53:44 +0000 | [diff] [blame] | 2 | |
Douglas Gregor | 1b12a3b | 2010-05-26 05:11:13 +0000 | [diff] [blame] | 3 | // Check mangling of Vtables, VTTs, and construction vtables that |
| 4 | // involve standard substitutions. |
| 5 | |
Anders Carlsson | f502d93 | 2011-01-24 00:46:19 +0000 | [diff] [blame] | 6 | // CHECK: @_ZTVSd = linkonce_odr unnamed_addr constant |
Peter Collingbourne | bf1c5ae | 2011-09-26 01:56:36 +0000 | [diff] [blame] | 7 | // CHECK: @_ZTTSd = linkonce_odr unnamed_addr constant |
John McCall | bda0d6b | 2011-03-27 09:00:25 +0000 | [diff] [blame] | 8 | // CHECK: @_ZTCSd0_Si = linkonce_odr unnamed_addr constant |
| 9 | // CHECK: @_ZTCSd16_So = linkonce_odr unnamed_addr constant |
Anders Carlsson | adf5dc3 | 2011-05-15 17:36:21 +0000 | [diff] [blame] | 10 | // CHECK: @_ZTVSo = linkonce_odr unnamed_addr constant |
Peter Collingbourne | bf1c5ae | 2011-09-26 01:56:36 +0000 | [diff] [blame] | 11 | // CHECK: @_ZTTSo = linkonce_odr unnamed_addr constant |
Anders Carlsson | 1cbce12 | 2011-01-29 19:16:51 +0000 | [diff] [blame] | 12 | // CHECK: @_ZTVSi = linkonce_odr unnamed_addr constant |
Peter Collingbourne | bf1c5ae | 2011-09-26 01:56:36 +0000 | [diff] [blame] | 13 | // CHECK: @_ZTTSi = linkonce_odr unnamed_addr constant |
Anders Carlsson | e3d6cf2 | 2011-05-16 04:08:36 +0000 | [diff] [blame] | 14 | |
Anders Carlsson | e7c8cb6 | 2009-09-26 20:53:44 +0000 | [diff] [blame] | 15 | namespace std { |
| 16 | struct A { A(); }; |
| 17 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 18 | // CHECK: define void @_ZNSt1AC1Ev(%"struct.std::A"* %this) unnamed_addr |
| 19 | // CHECK: define void @_ZNSt1AC2Ev(%"struct.std::A"* %this) unnamed_addr |
Anders Carlsson | e7c8cb6 | 2009-09-26 20:53:44 +0000 | [diff] [blame] | 20 | A::A() { } |
| 21 | }; |
Anders Carlsson | 8c03155 | 2009-09-26 23:10:05 +0000 | [diff] [blame] | 22 | |
| 23 | namespace std { |
Anders Carlsson | 8f8fd8e | 2009-10-08 17:20:26 +0000 | [diff] [blame] | 24 | template<typename> struct allocator { }; |
Anders Carlsson | 8c03155 | 2009-09-26 23:10:05 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Anders Carlsson | 8c03155 | 2009-09-26 23:10:05 +0000 | [diff] [blame] | 27 | // CHECK: define void @_Z1fSaIcESaIiE |
Anders Carlsson | fcd0029 | 2009-09-29 05:36:21 +0000 | [diff] [blame] | 28 | void f(std::allocator<char>, std::allocator<int>) { } |
Anders Carlsson | 189d59c | 2009-09-26 23:14:39 +0000 | [diff] [blame] | 29 | |
| 30 | namespace std { |
Anders Carlsson | 8f8fd8e | 2009-10-08 17:20:26 +0000 | [diff] [blame] | 31 | template<typename, typename, typename> struct basic_string { }; |
Anders Carlsson | 189d59c | 2009-09-26 23:14:39 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Anders Carlsson | f514b54 | 2009-09-27 00:12:57 +0000 | [diff] [blame] | 34 | // CHECK: define void @_Z1fSbIcciE |
Anders Carlsson | fcd0029 | 2009-09-29 05:36:21 +0000 | [diff] [blame] | 35 | void f(std::basic_string<char, char, int>) { } |
Anders Carlsson | f514b54 | 2009-09-27 00:12:57 +0000 | [diff] [blame] | 36 | |
| 37 | namespace std { |
Anders Carlsson | 8f8fd8e | 2009-10-08 17:20:26 +0000 | [diff] [blame] | 38 | template<typename> struct char_traits { }; |
Anders Carlsson | f514b54 | 2009-09-27 00:12:57 +0000 | [diff] [blame] | 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) { } |
Anders Carlsson | 8f8fd8e | 2009-10-08 17:20:26 +0000 | [diff] [blame] | 45 | |
| 46 | namespace std { |
Douglas Gregor | 1b12a3b | 2010-05-26 05:11:13 +0000 | [diff] [blame] | 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 | }; |
Anders Carlsson | 8f8fd8e | 2009-10-08 17:20:26 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Anders Carlsson | 91f8860 | 2009-12-07 19:56:42 +0000 | [diff] [blame] | 73 | // CHECK: _Z1fSi |
| 74 | void f(std::basic_istream<char, std::char_traits<char> >) { } |
| 75 | |
Anders Carlsson | 8f8fd8e | 2009-10-08 17:20:26 +0000 | [diff] [blame] | 76 | // CHECK: _Z1fSo |
| 77 | void f(std::basic_ostream<char, std::char_traits<char> >) { } |
Anders Carlsson | 47846d2 | 2009-12-04 06:23:23 +0000 | [diff] [blame] | 78 | |
Anders Carlsson | 91f8860 | 2009-12-07 19:56:42 +0000 | [diff] [blame] | 79 | // CHECK: _Z1fSd |
| 80 | void f(std::basic_iostream<char, std::char_traits<char> >) { } |
| 81 | |
Anders Carlsson | 47846d2 | 2009-12-04 06:23:23 +0000 | [diff] [blame] | 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 | } |
Eli Friedman | b1162f1 | 2010-02-23 18:20:18 +0000 | [diff] [blame] | 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) { } |
Douglas Gregor | 1b12a3b | 2010-05-26 05:11:13 +0000 | [diff] [blame] | 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 | } |
Anders Carlsson | c820f90 | 2010-06-02 15:58:27 +0000 | [diff] [blame] | 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 | } |