summaryrefslogtreecommitdiff
path: root/test/CoverageMapping
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin.dev@gmail.com>2016-06-07 02:17:03 +0000
committerIgor Kudrin <ikudrin.dev@gmail.com>2016-06-07 02:17:03 +0000
commitf962670a08ef14c8bc5eeeb991078593e0c2ae20 (patch)
treee28c59594025ec4768e60be8d285d57dcd6f9e98 /test/CoverageMapping
parent01203ed48e7813969a5995d2b57df6d31dec63ae (diff)
[Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.
We have an assertion failure if, for example, the definition of an unused inline function starts in one macro and ends in another. This patch fixes the issue by finding the common ancestor of the start and end locations of that function's body and changing the locations accordingly. Differential Revision: http://reviews.llvm.org/D20997 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CoverageMapping')
-rw-r--r--test/CoverageMapping/Inputs/ends_a_scope_only1
-rw-r--r--test/CoverageMapping/Inputs/starts_a_scope_only1
-rw-r--r--test/CoverageMapping/unused_function.cpp37
3 files changed, 39 insertions, 0 deletions
diff --git a/test/CoverageMapping/Inputs/ends_a_scope_only b/test/CoverageMapping/Inputs/ends_a_scope_only
new file mode 100644
index 0000000000..5c34318c21
--- /dev/null
+++ b/test/CoverageMapping/Inputs/ends_a_scope_only
@@ -0,0 +1 @@
+}
diff --git a/test/CoverageMapping/Inputs/starts_a_scope_only b/test/CoverageMapping/Inputs/starts_a_scope_only
new file mode 100644
index 0000000000..98232c64fc
--- /dev/null
+++ b/test/CoverageMapping/Inputs/starts_a_scope_only
@@ -0,0 +1 @@
+{
diff --git a/test/CoverageMapping/unused_function.cpp b/test/CoverageMapping/unused_function.cpp
new file mode 100644
index 0000000000..b50b089379
--- /dev/null
+++ b/test/CoverageMapping/unused_function.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+#define START_SCOPE {
+#define END_SCOPE }
+
+// CHECK: _Z2f0v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:20 = 0
+inline void f0() {}
+
+// CHECK: _Z2f1v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:31 = 0
+inline void f1() START_SCOPE }
+
+// CHECK: _Z2f2v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:29 = 0
+inline void f2() { END_SCOPE
+
+// CHECK: _Z2f3v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:39 = 0
+inline void f3() START_SCOPE END_SCOPE
+
+// CHECK: _Z2f4v:
+// CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:2 = 0
+inline void f4()
+#include "Inputs/starts_a_scope_only"
+}
+
+// CHECK: _Z2f5v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+2]]:36 = 0
+inline void f5() {
+#include "Inputs/ends_a_scope_only"
+
+// CHECK: _Z2f6v:
+// CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:36 = 0
+inline void f6()
+#include "Inputs/starts_a_scope_only"
+#include "Inputs/ends_a_scope_only"