classtemplate.cpp 2.2 KB

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