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