xref: /minix3/external/bsd/llvm/dist/clang/test/CoverageMapping/classtemplate.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple %itanium_abi_triple -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name classtemplate.cpp %s > %tmapping
2*0a6a1f1dSLionel Sambuc // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-CONSTRUCTOR
3*0a6a1f1dSLionel Sambuc // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-GETTER
4*0a6a1f1dSLionel Sambuc // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-SETTER
5*0a6a1f1dSLionel Sambuc 
6*0a6a1f1dSLionel Sambuc template<class TT>
7*0a6a1f1dSLionel Sambuc class Test {
8*0a6a1f1dSLionel Sambuc public:
9*0a6a1f1dSLionel Sambuc   enum BaseType {
10*0a6a1f1dSLionel Sambuc     A, C, G, T, Invalid
11*0a6a1f1dSLionel Sambuc   };
12*0a6a1f1dSLionel Sambuc   const static int BaseCount = 4;
13*0a6a1f1dSLionel Sambuc   double bases[BaseCount];
14*0a6a1f1dSLionel Sambuc 
15*0a6a1f1dSLionel Sambuc                                         // CHECK-CONSTRUCTOR: _ZN4TestIjEC
Test()16*0a6a1f1dSLionel Sambuc   Test() { }                            // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:10 -> [[@LINE]]:13 = #0 (HasCodeBefore = 0)
17*0a6a1f1dSLionel Sambuc 
18*0a6a1f1dSLionel Sambuc   // FIXME: It would be nice to emit no-coverage for get, but trying to do this
19*0a6a1f1dSLionel Sambuc   // runs afoul of cases like Test3::unmangleable below.
20*0a6a1f1dSLionel Sambuc                                         // FIXME-GETTER: _ZNK4TestIjE3get
get(TT position) const21*0a6a1f1dSLionel Sambuc   double get(TT position) const {       // FIXME-GETTER: File 0, [[@LINE]]:33 -> [[@LINE+2]]:4 = 0 (HasCodeBefore = 0)
22*0a6a1f1dSLionel Sambuc     return bases[position];
23*0a6a1f1dSLionel Sambuc   }
24*0a6a1f1dSLionel Sambuc                                         // CHECK-SETTER: _ZN4TestIjE3set
set(TT position,double value)25*0a6a1f1dSLionel Sambuc   void set(TT position, double value) { // CHECK-SETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = #0 (HasCodeBefore = 0)
26*0a6a1f1dSLionel Sambuc     bases[position] = value;
27*0a6a1f1dSLionel Sambuc   }
28*0a6a1f1dSLionel Sambuc };
29*0a6a1f1dSLionel Sambuc 
30*0a6a1f1dSLionel Sambuc class Test2 {
31*0a6a1f1dSLionel Sambuc                                         // CHECK-CONSTRUCTOR: _ZN5Test2C
Test2()32*0a6a1f1dSLionel Sambuc   Test2() { }                           // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:11 -> [[@LINE]]:14 = 0 (HasCodeBefore = 0)
33*0a6a1f1dSLionel Sambuc                                         // CHECK-GETTER: _ZNK5Test23get
get(unsigned position) const34*0a6a1f1dSLionel Sambuc   double get(unsigned position) const { // CHECK-GETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = 0 (HasCodeBefore = 0)
35*0a6a1f1dSLionel Sambuc     return 0.0;
36*0a6a1f1dSLionel Sambuc   }
37*0a6a1f1dSLionel Sambuc };
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc // Test3::unmangleable can't be mangled, since there isn't a complete type for
40*0a6a1f1dSLionel Sambuc // the __is_final type trait expression. This would cause errors if we try to
41*0a6a1f1dSLionel Sambuc // emit a no-coverage mapping for the method.
42*0a6a1f1dSLionel Sambuc template <class T, bool = __is_final(T)> class UninstantiatedClassWithTraits {};
43*0a6a1f1dSLionel Sambuc template <class T> class Test3 {
unmangleable(UninstantiatedClassWithTraits<T> x)44*0a6a1f1dSLionel Sambuc   void unmangleable(UninstantiatedClassWithTraits<T> x) {}
45*0a6a1f1dSLionel Sambuc };
46*0a6a1f1dSLionel Sambuc 
main()47*0a6a1f1dSLionel Sambuc int main() {
48*0a6a1f1dSLionel Sambuc   Test<unsigned> t;
49*0a6a1f1dSLionel Sambuc   t.set(Test<unsigned>::A, 5.5);
50*0a6a1f1dSLionel Sambuc   t.set(Test<unsigned>::T, 5.6);
51*0a6a1f1dSLionel Sambuc   t.set(Test<unsigned>::G, 5.7);
52*0a6a1f1dSLionel Sambuc   t.set(Test<unsigned>::C, 5.8);
53*0a6a1f1dSLionel Sambuc   return 0;
54*0a6a1f1dSLionel Sambuc }
55