Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / debug-info-use-after-free.cpp
blob1001248897346a118ed0be80fd0bd52a657989fb
1 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only %s
2 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only -std=c++98 %s
3 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only -std=c++11 %s
4 // Check that we don't crash.
5 // PR12305, PR12315
7 # 1 "a.h" 3
8 template < typename T1 > struct Types1
10 typedef T1 Head;
12 template < typename > struct Types;
13 template < template < typename > class Tmpl > struct TemplateSel
15 template < typename T > struct Bind
17 typedef Tmpl < T > type;
20 template < typename > struct NoneT;
21 template < template < typename > class T1, template < typename > class > struct Templates2
23 typedef TemplateSel < T1 > Head;
25 template < template < typename > class, template < typename > class =
26 NoneT, template < typename > class = NoneT, template < typename > class =
27 NoneT > struct Templates;
28 template < template < typename > class T1,
29 template < typename > class T2 > struct Templates <T1, T2 >
31 typedef Templates2 < T1, T2 > type;
33 template < typename T > struct TypeList
35 typedef Types1 < T > type;
37 template < template < typename > class, class TestSel,
38 typename Types > class TypeParameterizedTest
40 public:static bool Register ()
42 typedef typename Types::Head Type;
43 typename TestSel::template Bind < Type >::type TestClass;
44 }};
46 template < template < typename > class Fixture, typename Tests,
47 typename Types > class TypeParameterizedTestCase
49 public:static bool Register (char *, char *, int *)
51 typedef typename Tests::Head Head;
52 TypeParameterizedTest < Fixture, Head, Types >::Register;
53 }};
55 template < typename > class TypedTestP1
59 namespace gtest_case_TypedTestP1_
61 template < typename gtest_TypeParam_ > class A:TypedTestP1 <
62 gtest_TypeParam_ >
65 template < typename gtest_TypeParam_ > class B:TypedTestP1 <
66 gtest_TypeParam_ >
69 typedef Templates < A >::type gtest_AllTests_;
72 template < typename > class TypedTestP2
76 namespace gtest_case_TypedTestP2_
78 template < typename gtest_TypeParam_ > class A:TypedTestP2 <
79 gtest_TypeParam_ >
82 typedef Templates < A >::type gtest_AllTests_;
85 bool gtest_Int_TypedTestP1 =
86 TypeParameterizedTestCase < TypedTestP1,
87 gtest_case_TypedTestP1_::gtest_AllTests_,
88 TypeList < int >::type >::Register ("Int", "TypedTestP1", 0);
89 bool gtest_Int_TypedTestP2 =
90 TypeParameterizedTestCase < TypedTestP2,
91 gtest_case_TypedTestP2_::gtest_AllTests_,
92 TypeList < Types < int > >::type >::Register ("Int", "TypedTestP2", 0);
94 template < typename _Tp > struct new_allocator
96 typedef _Tp *pointer;
97 template < typename > struct rebind {
98 typedef new_allocator other;
101 template < typename _Tp > struct allocator:new_allocator < _Tp > {
103 template < typename _Tp, typename _Alloc > struct _Vector_base {
104 typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type;
105 struct _Vector_impl {
106 typename _Tp_alloc_type::pointer _M_end_of_storage;
108 _Vector_base () {
109 foo((int *) this->_M_impl._M_end_of_storage);
111 void foo(int *);
112 _Vector_impl _M_impl;
114 template < typename _Tp, typename _Alloc =
115 allocator < _Tp > >struct vector:_Vector_base < _Tp, _Alloc > { };
118 template < class T> struct HHH {};
119 struct DDD { int x_;};
120 struct Data;
121 struct X1;
122 struct CCC:DDD { virtual void xxx (HHH < X1 >); };
123 template < class SSS > struct EEE:vector < HHH < SSS > > { };
124 template < class SSS, class = EEE < SSS > >class FFF { };
125 template < class SSS, class GGG = EEE < SSS > >class AAA:FFF <GGG> { };
126 class BBB:virtual CCC {
127 void xxx (HHH < X1 >);
128 vector < HHH < X1 > >aaa;
130 class ZZZ:AAA < Data >, BBB { virtual ZZZ *ppp () ; };
131 ZZZ * ZZZ::ppp () { return new ZZZ; }
133 namespace std
135 template < class, class > struct pair;
137 namespace __gnu_cxx {
138 template < typename > class new_allocator;
140 namespace std {
141 template < typename _Tp > class allocator:__gnu_cxx::new_allocator < _Tp > {
143 template < typename, typename > struct _Vector_base {
145 template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class vector:_Vector_base < _Tp,
146 _Alloc
151 namespace
152 std {
153 template <
154 typename,
155 typename > struct unary_function;
156 template <
157 typename,
158 typename,
159 typename > struct binary_function;
160 template <
161 typename
162 _Tp > struct equal_to:
163 binary_function <
164 _Tp,
165 _Tp,
166 bool > {
168 template <
169 typename
170 _Pair > struct _Select1st:
171 unary_function <
172 _Pair,
173 typename
174 _Pair::first_type > {
177 # 1 "f.h" 3
178 using
179 std::pair;
180 namespace
181 __gnu_cxx {
182 template <
183 class > struct hash;
184 template <
185 class,
186 class,
187 class,
188 class,
189 class
190 _EqualKey,
191 class >
192 class
193 hashtable {
194 public:
195 typedef _EqualKey
196 key_equal;
197 typedef void key_type;
199 using
200 std::equal_to;
201 using
202 std::allocator;
203 using
204 std::_Select1st;
205 template < class _Key, class _Tp, class _HashFn =
206 hash < _Key >, class _EqualKey = equal_to < _Key >, class _Alloc =
207 allocator < _Tp > >class hash_map {
208 typedef
209 hashtable <
210 pair <
211 _Key,
212 _Tp >,
213 _Key,
214 _HashFn,
215 _Select1st <
216 pair <
217 _Key,
218 _Tp > >,
219 _EqualKey,
220 _Alloc >
221 _Ht;
222 public:
223 typedef typename _Ht::key_type key_type;
224 typedef typename
225 _Ht::key_equal
226 key_equal;
229 using
230 __gnu_cxx::hash_map;
231 class
233 template < class > class scoped_ptr {
235 namespace {
236 class
237 AAA {
238 protected:
239 virtual ~
240 AAA () {
243 template < typename > class EEE;
244 template < typename CCC, typename =
245 typename CCC::key_equal, typename =
246 EEE < CCC > >class III {
248 namespace
249 util {
250 class
251 EEE {
254 namespace {
255 class
257 util::EEE {
258 public:
259 class
261 AAA {
262 struct FFF;
263 typedef
264 III <
265 hash_map <
267 FFF > >
268 GGG;
270 aaa;
271 friend
274 void
275 HHH (C3::GGG &);
278 namespace
279 n1 {
280 class
281 Test {
283 template <
284 typename >
285 class
286 C7 {
288 class
290 n1::Test {
291 vector <
292 C1::C3 * >
295 enum C5 { };
296 class
299 n1::C7 <
300 C5 > {
302 class
304 C6 {
306 class
308 C8 {
309 void
310 TestBody ();
312 void
313 C9::TestBody () {
314 scoped_ptr < C1::C3 > context;