brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 5151f8c Raw
104 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG7 8template<typename T, typename U>9class Templ {};10 11template<typename T>12class Templ<T, int>{};13 14Templ<int, int> t;15 16// CIR: !rec_Templ3Cint2C_int3E = !cir.record<class "Templ<int, int>" padded {!u8i}>17// CIR: cir.global external @t = #cir.zero : !rec_Templ3Cint2C_int3E18 19// LLVM: %"class.Templ<int, int>" = type { i8 }20// LLVM: @t = global %"class.Templ<int, int>" zeroinitializer21 22// OGCG: %class.Templ = type { i8 }23// OGCG: @t = global %class.Templ zeroinitializer24 25template<class T>26class X {27public:28  int f() { return 0; }29};30 31template<> class X<int> {32public:33  int f() { return 1; }34};35 36void test_double() {37  X<double> d;38  d.f();39}40 41// CIR: cir.func{{.*}} @_ZN1XIdE1fEv42// CIR:   cir.const #cir.int<0>43//44// CIR: cir.func{{.*}} @_Z11test_doublev()45// CIR:   cir.call @_ZN1XIdE1fEv46 47// LLVM: define{{.*}} i32 @_ZN1XIdE1fEv48// LLVM:   store i32 049//50// LLVM: define{{.*}} void @_Z11test_doublev()51// LLVM:   call i32 @_ZN1XIdE1fEv52 53// OGCG: define{{.*}} void @_Z11test_doublev()54// OGCG:   call{{.*}} i32 @_ZN1XIdE1fEv55//56// OGCG: define{{.*}} i32 @_ZN1XIdE1fEv57// OGCG:   ret i32 058 59void test_int() {60  X<int> n;61  n.f();62}63 64// CIR: cir.func{{.*}} @_ZN1XIiE1fEv65// CIR:   cir.const #cir.int<1>66//67// CIR: cir.func{{.*}} @_Z8test_intv()68// CIR:   cir.call @_ZN1XIiE1fEv69 70// LLVM: define{{.*}} i32 @_ZN1XIiE1fEv71// LLVM:   store i32 172//73// LLVM: define{{.*}} void @_Z8test_intv()74// LLVM:   call i32 @_ZN1XIiE1fEv75 76// OGCG: define{{.*}} void @_Z8test_intv()77// OGCG:   call{{.*}} i32 @_ZN1XIiE1fEv78//79// OGCG: define{{.*}} i32 @_ZN1XIiE1fEv80// OGCG:   ret i32 181 82void test_short() {83  X<short> s;84  s.f();85}86 87// CIR: cir.func{{.*}} @_ZN1XIsE1fEv88// CIR:   cir.const #cir.int<0>89//90// CIR: cir.func{{.*}} @_Z10test_shortv()91// CIR:   cir.call @_ZN1XIsE1fEv92 93// LLVM: define{{.*}} i32 @_ZN1XIsE1fEv94// LLVM: store i32 095//96// LLVM: define{{.*}} void @_Z10test_shortv()97// LLVM:   call i32 @_ZN1XIsE1fEv98 99// OGCG: define{{.*}} void @_Z10test_shortv()100// OGCG:   call{{.*}} i32 @_ZN1XIsE1fEv101//102// OGCG: define{{.*}} i32 @_ZN1XIsE1fEv103// OGCG:   ret i32 0104