[PGO] Simpflify test and increase coverage
authorXinliang David Li <davidxl@google.com>
Mon, 8 Feb 2016 20:46:26 +0000 (20:46 +0000)
committerXinliang David Li <davidxl@google.com>
Mon, 8 Feb 2016 20:46:26 +0000 (20:46 +0000)
llvm-svn: 260142

compiler-rt/test/profile/Linux/coverage_ctors.cpp
compiler-rt/test/profile/Linux/coverage_dtor.cpp

index cb8b120..fe4a2be 100644 (file)
@@ -5,28 +5,28 @@
 
 struct Base {
   int B;
-  Base() : B(2) {}
-  Base(const struct Base &b2) {
-    if (b2.B == 0) {
-      B = b2.B + 1;
-    } else
-      B = b2.B;
+  Base() : B(0) {}
+  Base(const Base &b2) {
+    B = b2.B + 5;
+  }
+  Base(Base &&b2) {
+    B = b2.B + 10;
   }
 };
 
 struct Derived : public Base {
   Derived(const Derived &) = default; // CHECK:  2| [[@LINE]]|  Derived(const Derived &) = default;
+  Derived(Derived &&) = default;      // CHECK:  1| [[@LINE]]|  Derived(Derived &&) = default;
   Derived() = default;                // CHECK:  1| [[@LINE]]|  Derived() = default
-  int I;
-  int getI() { return I; }
 };
 
 Derived dd;
-int g;
 int main() {
   Derived dd2(dd);
-  Derived dd3(dd);
+  Derived dd3(dd2);
+  Derived dd4(static_cast<Derived &&>(dd3));
 
-  g = dd2.getI() + dd3.getI();
+  if (dd.B != 0 || dd2.B != 5 || dd3.B != 10 || dd4.B != 20)
+    return 1;                         // CHECK: 0| [[@LINE]]|     return 1;
   return 0;
 }
index 8a4a039..c59c34d 100644 (file)
@@ -3,23 +3,24 @@
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
 // RUN: llvm-cov show %t -instr-profile %t.profdata -filename-equivalence 2>&1 | FileCheck %s
 
+int g = 100;
 struct Base {
   int B;
   Base(int B_) : B(B_) {}
-  ~Base() {}
+  ~Base() { g -= B; }
 };
 
 struct Derived : public Base {
-  Derived(int K) : Base(K), I(K) {}
+  Derived(int K) : Base(K) {}
   ~Derived() = default; // CHECK:  2| [[@LINE]]|  ~Derived() = default;
-  int I;
-  int getI() { return I; }
 };
 
-int g;
 int main() {
-  Derived dd(10);
-  Derived dd2(120);
-  g = dd2.getI() + dd.getI();
+  {
+    Derived dd(10);
+    Derived dd2(90);
+  }
+  if (g != 0)
+    return 1;          // CHECK:  0| [[@LINE]]|    return 1;
   return 0;
 }