diff options
| author | Xinliang David Li <davidxl@google.com> | 2016-02-07 16:31:13 +0000 |
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2016-02-07 16:31:13 +0000 |
| commit | abf6d973f4bdc6c869a3ea6c01de6c436bd43c0b (patch) | |
| tree | 3bbb90cdc4722013dd37dd45dda605b700db928e | |
| parent | 38a8a5fc1d372f9013751cfb081b7bb966c5acfb (diff) | |
| download | bcm5719-llvm-abf6d973f4bdc6c869a3ea6c01de6c436bd43c0b.tar.gz bcm5719-llvm-abf6d973f4bdc6c869a3ea6c01de6c436bd43c0b.zip | |
Add coverage tests (defaulted constructors/destructor)
llvm-svn: 260041
| -rw-r--r-- | compiler-rt/test/profile/Linux/coverage_ctors.cpp | 33 | ||||
| -rw-r--r-- | compiler-rt/test/profile/Linux/coverage_dtor.cpp | 26 |
2 files changed, 59 insertions, 0 deletions
diff --git a/compiler-rt/test/profile/Linux/coverage_ctors.cpp b/compiler-rt/test/profile/Linux/coverage_ctors.cpp new file mode 100644 index 00000000000..336cf147ca1 --- /dev/null +++ b/compiler-rt/test/profile/Linux/coverage_ctors.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_profgen -x c++ -std=c++11 -fuse-ld=gold -fcoverage-mapping -o %t %s +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t +// RUN: llvm-profdata merge -o %t.profdata %t.profraw +// RUN: llvm-cov show %t -instr-profile %t.profdata -filename-equivalence 2>&1 | FileCheck %s + +struct Base { + int B; + Base() : B(2) {} + Base(const struct Base &b2) { + if (b2.B == 0) { + B = b2.B + 1; + } else + B = b2.B; + } +}; + +struct Derived : public Base { + Derived(const Derived &) = default; // CHECK: 2| [[@LINE]]| Derived + Derived() = default; // CHECK: 1| [[@LINE]]| Derived + int I; + int J; + int getI() { return I; } +}; + +Derived dd; +int g; +int main() { + Derived dd2(dd); + Derived dd3(dd); + + g = dd2.getI() + dd3.getI(); + return 0; +} diff --git a/compiler-rt/test/profile/Linux/coverage_dtor.cpp b/compiler-rt/test/profile/Linux/coverage_dtor.cpp new file mode 100644 index 00000000000..b24bfb8a4a4 --- /dev/null +++ b/compiler-rt/test/profile/Linux/coverage_dtor.cpp @@ -0,0 +1,26 @@ +// RUN: %clang -x c++ -fno-exceptions -std=c++11 -fuse-ld=gold -fprofile-instr-generate -fcoverage-mapping -o %t %s +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t +// RUN: llvm-profdata merge -o %t.profdata %t.profraw +// RUN: llvm-cov show %t -instr-profile %t.profdata -filename-equivalence 2>&1 | FileCheck %s + +struct Base { + int B; + Base(int B_) : B(B_) {} + ~Base() {} +}; + +struct Derived : public Base { + Derived(int K) : Base(K), I(K), J(K) {} + ~Derived() = default; // CHECK: 2| [[@LINE]]| ~Derived + int I; + int J; + int getI() { return I; } +}; + +int g; +int main() { + Derived dd(10); + Derived dd2(120); + g = dd2.getI() + dd.getI(); + return 0; +} |

