blob: 3df487a33f3c85fc54f9e4e0dc7fe5c4224705cb [file] [log] [blame]
David Blaikie66cff722012-11-14 01:52:05 +00001// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -w -o - | FileCheck %s
Chandler Carruth17fb8552010-09-03 21:12:34 +00002
3struct S {
4 enum { FOO = 42 };
5 enum { BAR = 42 };
6};
7
8template <typename T> struct X {
9 T value;
Chandler Carruth17fb8552010-09-03 21:12:34 +000010 X(T t) : value(t) {}
Chandler Carruth17fb8552010-09-03 21:12:34 +000011 int f() { return value; }
12};
13
14template <typename T> int f(T t) {
15 X<T> x(t);
16 return x.f();
17}
18
19void test() {
David Blaikie66cff722012-11-14 01:52:05 +000020 // Look for two instantiations, one for FOO's
Chandler Carruth17fb8552010-09-03 21:12:34 +000021 // type and one for BAR's.
David Blaikie66cff722012-11-14 01:52:05 +000022 // CHECK: define linkonce_odr i32 @_Z1fIN1SUt_EEiT_(i32 %t)
Chandler Carruth17fb8552010-09-03 21:12:34 +000023 (void)f(S::FOO);
David Blaikie66cff722012-11-14 01:52:05 +000024 // CHECK: define linkonce_odr i32 @_Z1fIN1SUt0_EEiT_(i32 %t)
Chandler Carruth17fb8552010-09-03 21:12:34 +000025 (void)f(S::BAR);
26
27 // Now check for the class template instantiations. Annoyingly, they are in
28 // reverse order.
29 //
30 // BAR's instantiation of X:
David Blaikie66cff722012-11-14 01:52:05 +000031 // CHECK: define linkonce_odr i32 @_ZN1XIN1SUt0_EE1fEv(%struct.X* %this)
32 // CHECK: define linkonce_odr void @_ZN1XIN1SUt0_EEC2ES1_(%struct.X* %this, i32 %t) unnamed_addr
Chandler Carruth17fb8552010-09-03 21:12:34 +000033 //
34 // FOO's instantiation of X:
David Blaikie66cff722012-11-14 01:52:05 +000035 // CHECK: define linkonce_odr i32 @_ZN1XIN1SUt_EE1fEv(%struct.X.0* %this)
36 // CHECK: define linkonce_odr void @_ZN1XIN1SUt_EEC2ES1_(%struct.X.0* %this, i32 %t) unnamed_addr
Chandler Carruth17fb8552010-09-03 21:12:34 +000037}