brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · d98e4de Raw
96 lines · cpp
1// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name classtemplate.cpp %s > %tmapping2// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-CONSTRUCTOR3// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-GETTER4// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-SETTER5// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-INIT-LIST6 7template<class TT>8class Test {9public:10  enum BaseType {11    A, C, G, T, Invalid12  };13  const static int BaseCount = 4;14  double bases[BaseCount];15 16                                        // CHECK-CONSTRUCTOR: _ZN4TestIjEC17  Test() { }                            // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:10 -> [[@LINE]]:13 = #018 19  // FIXME: It would be nice to emit no-coverage for get, but trying to do this20  // runs afoul of cases like Test3::unmangleable below.21                                        // FIXME-GETTER: _ZNK4TestIjE3get22  double get(TT position) const {       // FIXME-GETTER: File 0, [[@LINE]]:33 -> [[@LINE+2]]:4 = 023    return bases[position];24  }25                                        // CHECK-SETTER: _ZN4TestIjE3set26  void set(TT position, double value) { // CHECK-SETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = #027    bases[position] = value;28  }29};30 31class Test2 {32                                        // CHECK-CONSTRUCTOR: _ZN5Test2C33  Test2() { }                           // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:11 -> [[@LINE]]:14 = 034                                        // CHECK-GETTER: _ZNK5Test23get35  double get(unsigned position) const { // CHECK-GETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = 036    return 0.0;37  }38};39 40// Test3::unmangleable can't be mangled, since there isn't a complete type for41// the __is_final type trait expression. This would cause errors if we try to42// emit a no-coverage mapping for the method.43template <class T, bool = __is_final(T)> class UninstantiatedClassWithTraits {};44template <class T> class Test3 {45  void unmangleable(UninstantiatedClassWithTraits<T> x) {}46};47 48void abort() __attribute__((noreturn));49 50namespace std {51typedef decltype(sizeof(int)) size_t;52 53template <typename E> struct initializer_list {54  const E *p;55  size_t n;56  initializer_list(const E *p, size_t n) : p(p), n(n) {}57};58 59template <typename F, typename S> struct pair {60  F f;61  S s;62  pair(const F &f, const S &s) : f(f), s(s) {}63};64 65struct string {66  const char *str;67  string() { abort(); }68  string(const char *S) : str(S) {}69  ~string() { abort(); }70};71 72template<typename K, typename V>73struct map {74  using T = pair<K, V>;75  map(initializer_list<T> i, const string &s = string()) {}76  ~map() { abort(); }77};78 79}; // namespace std80 81// CHECK-INIT-LIST-LABEL: _Z5Test4v:82std::map<int, int> Test4() { // CHECK-INIT-LIST: File 0, [[@LINE]]:28 -> [[@LINE+3]]:2 = #083  abort();                           // CHECK-INIT-LIST-NEXT: Gap,File 0, [[@LINE]]:11 -> [[@LINE+1]]:3 = 084  return std::map<int, int>{{0, 0}}; // CHECK-INIT-LIST-NEXT: [[@LINE]]:3 -> [[@LINE]]:36 = 085}86 87int main() {88  Test<unsigned> t;89  t.set(Test<unsigned>::A, 5.5);90  t.set(Test<unsigned>::T, 5.6);91  t.set(Test<unsigned>::G, 5.7);92  t.set(Test<unsigned>::C, 5.8);93  Test4();94  return 0;95}96