Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 1 | // 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 | // 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 |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 16 | Test() { } // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:10 -> [[@LINE]]:13 = #0 |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 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 |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 21 | double get(TT position) const { // FIXME-GETTER: File 0, [[@LINE]]:33 -> [[@LINE+2]]:4 = 0 |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 22 | return bases[position]; |
| 23 | } |
| 24 | // CHECK-SETTER: _ZN4TestIjE3set |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 25 | void set(TT position, double value) { // CHECK-SETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = #0 |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 26 | bases[position] = value; |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | class Test2 { |
| 31 | // CHECK-CONSTRUCTOR: _ZN5Test2C |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 32 | Test2() { } // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:11 -> [[@LINE]]:14 = 0 |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 33 | // CHECK-GETTER: _ZNK5Test23get |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 34 | double get(unsigned position) const { // CHECK-GETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = 0 |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 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 | } |