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