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