blob: 63685efbfa0a250b2c5c9bf3e91ee0717c94de4e [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.
Stephen Lin93ab6bf2013-08-15 06:47:53 +000022 // CHECK-LABEL: define linkonce_odr i32 @_Z1fIN1SUt_EEiT_(i32 %t)
Chandler Carruth17fb8552010-09-03 21:12:34 +000023 (void)f(S::FOO);
Stephen Lin93ab6bf2013-08-15 06:47:53 +000024 // CHECK-LABEL: define linkonce_odr i32 @_Z1fIN1SUt0_EEiT_(i32 %t)
Chandler Carruth17fb8552010-09-03 21:12:34 +000025 (void)f(S::BAR);
26
Stephen Hines0e2c34f2015-03-23 12:09:02 -070027 // Now check for the class template instantiations.
Chandler Carruth17fb8552010-09-03 21:12:34 +000028 //
29 // BAR's instantiation of X:
Stephen Hines0e2c34f2015-03-23 12:09:02 -070030 // CHECK-LABEL: define linkonce_odr i32 @_ZN1XIN1SUt_EE1fEv(%struct.X* %this)
31 // CHECK-LABEL: define linkonce_odr void @_ZN1XIN1SUt_EEC2ES1_(%struct.X* %this, i32 %t) unnamed_addr
Chandler Carruth17fb8552010-09-03 21:12:34 +000032 //
33 // FOO's instantiation of X:
Stephen Hines0e2c34f2015-03-23 12:09:02 -070034 // CHECK-LABEL: define linkonce_odr i32 @_ZN1XIN1SUt0_EE1fEv(%struct.X.0* %this)
35 // CHECK-LABEL: define linkonce_odr void @_ZN1XIN1SUt0_EEC2ES1_(%struct.X.0* %this, i32 %t) unnamed_addr
Chandler Carruth17fb8552010-09-03 21:12:34 +000036}