blob: 2e0b50772da7c93c97cd05fce736c37542fb38fc [file] [log] [blame]
Stephen Hines176edba2014-12-01 14:53:08 -08001// 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
6template<class TT>
7class Test {
8public:
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 Hines0e2c34f2015-03-23 12:09:02 -070016 Test() { } // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:10 -> [[@LINE]]:13 = #0
Stephen Hines176edba2014-12-01 14:53:08 -080017
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 Hines0e2c34f2015-03-23 12:09:02 -070021 double get(TT position) const { // FIXME-GETTER: File 0, [[@LINE]]:33 -> [[@LINE+2]]:4 = 0
Stephen Hines176edba2014-12-01 14:53:08 -080022 return bases[position];
23 }
24 // CHECK-SETTER: _ZN4TestIjE3set
Stephen Hines0e2c34f2015-03-23 12:09:02 -070025 void set(TT position, double value) { // CHECK-SETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = #0
Stephen Hines176edba2014-12-01 14:53:08 -080026 bases[position] = value;
27 }
28};
29
30class Test2 {
31 // CHECK-CONSTRUCTOR: _ZN5Test2C
Stephen Hines0e2c34f2015-03-23 12:09:02 -070032 Test2() { } // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:11 -> [[@LINE]]:14 = 0
Stephen Hines176edba2014-12-01 14:53:08 -080033 // CHECK-GETTER: _ZNK5Test23get
Stephen Hines0e2c34f2015-03-23 12:09:02 -070034 double get(unsigned position) const { // CHECK-GETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = 0
Stephen Hines176edba2014-12-01 14:53:08 -080035 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.
42template <class T, bool = __is_final(T)> class UninstantiatedClassWithTraits {};
43template <class T> class Test3 {
44 void unmangleable(UninstantiatedClassWithTraits<T> x) {}
45};
46
47int 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}