1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc struct S { S(); ~S(); S(const S &); void operator()(int); };
4*f4a2713aSLionel Sambuc using size_t = decltype(sizeof(int));
5*f4a2713aSLionel Sambuc S operator"" _x(const char *, size_t);
6*f4a2713aSLionel Sambuc S operator"" _y(wchar_t);
7*f4a2713aSLionel Sambuc S operator"" _z(unsigned long long);
8*f4a2713aSLionel Sambuc S operator"" _f(long double);
9*f4a2713aSLionel Sambuc S operator"" _r(const char *);
operator ""_t()10*f4a2713aSLionel Sambuc template<char...Cs> S operator"" _t() { return S(); }
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc // CHECK: @[[s_foo:.*]] = {{.*}} constant [4 x i8] c"foo\00"
13*f4a2713aSLionel Sambuc // CHECK: @[[s_bar:.*]] = {{.*}} constant [4 x i8] c"bar\00"
14*f4a2713aSLionel Sambuc // CHECK: @[[s_123:.*]] = {{.*}} constant [4 x i8] c"123\00"
15*f4a2713aSLionel Sambuc // CHECK: @[[s_4_9:.*]] = {{.*}} constant [4 x i8] c"4.9\00"
16*f4a2713aSLionel Sambuc // CHECK: @[[s_0xffffeeee:.*]] = {{.*}} constant [11 x i8] c"0xffffeeee\00"
17*f4a2713aSLionel Sambuc
f()18*f4a2713aSLionel Sambuc void f() {
19*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_foo]], i32 0, i32 0), i64 3)
20*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_bar]], i32 0, i32 0), i64 3)
21*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_yw({{.*}} 97)
22*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_zy({{.*}} 42)
23*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_fe({{.*}} x86_fp80 0xK3FFF8000000000000000)
24*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
25*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
26*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
27*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
28*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
29*f4a2713aSLionel Sambuc "foo"_x, "bar"_x, L'a'_y, 42_z, 1.0_f;
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_123]], i32 0, i32 0))
32*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_4_9]], i32 0, i32 0))
33*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([11 x i8]* @[[s_0xffffeeee]], i32 0, i32 0))
34*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
35*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
36*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
37*f4a2713aSLionel Sambuc 123_r, 4.9_r, 0xffff\
38*f4a2713aSLionel Sambuc eeee_r;
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc // FIXME: This mangling is insane. Maybe we should have a special case for
41*f4a2713aSLionel Sambuc // char parameter packs?
42*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_tIJLc48ELc120ELc49ELc50ELc51ELc52ELc53ELc54ELc55ELc56EEE1Sv({{.*}})
43*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev({{.*}})
44*f4a2713aSLionel Sambuc 0x12345678_t;
45*f4a2713aSLionel Sambuc }
46*f4a2713aSLionel Sambuc
47*f4a2713aSLionel Sambuc // CHECK: define {{.*}} @_Zli2_tIJLc48ELc120ELc49ELc50ELc51ELc52ELc53ELc54ELc55ELc56EEE1Sv(
48*f4a2713aSLionel Sambuc
g(T t)49*f4a2713aSLionel Sambuc template<typename T> auto g(T t) -> decltype("foo"_x(t)) { return "foo"_x(t); }
i(T t)50*f4a2713aSLionel Sambuc template<typename T> auto i(T t) -> decltype(operator"" _x("foo", 3)(t)) { return operator"" _x("foo", 3)(t); }
51*f4a2713aSLionel Sambuc
h()52*f4a2713aSLionel Sambuc void h() {
53*f4a2713aSLionel Sambuc g(42);
54*f4a2713aSLionel Sambuc i(42);
55*f4a2713aSLionel Sambuc }
56*f4a2713aSLionel Sambuc
57*f4a2713aSLionel Sambuc // CHECK: define {{.*}} @_Z1hv()
58*f4a2713aSLionel Sambuc // CHECK: call void @_Z1gIiEDTclclL_Zli2_xPKcmELA4_S0_ELm3EEfp_EET_(i32 42)
59*f4a2713aSLionel Sambuc // CHECK: call void @_Z1iIiEDTclclL_Zli2_xPKcmELA4_S0_ELi3EEfp_EET_(i32 42)
60*f4a2713aSLionel Sambuc
61*f4a2713aSLionel Sambuc // CHECK: define {{.*}} @_Z1gIiEDTclclL_Zli2_xPKcmELA4_S0_ELm3EEfp_EET_(i32
62*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @{{.*}}, i32 0, i32 0), i64 3)
63*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SclEi
64*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev
65*f4a2713aSLionel Sambuc
66*f4a2713aSLionel Sambuc // CHECK: define {{.*}} @_Z1iIiEDTclclL_Zli2_xPKcmELA4_S0_ELi3EEfp_EET_(i32
67*f4a2713aSLionel Sambuc // CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @{{.*}}, i32 0, i32 0), i64 3)
68*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SclEi
69*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1SD1Ev
70