summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-cov
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin.dev@gmail.com>2016-04-15 14:56:50 +0000
committerIgor Kudrin <ikudrin.dev@gmail.com>2016-04-15 14:56:50 +0000
commit061d496c511b02a0c2bd394539c757c5ad4511e3 (patch)
tree2a74d228a4d1a319e950414d2b4b078507494716 /llvm/test/tools/llvm-cov
parent81433e99b9a770ccbd086b80390031a4ea708dbd (diff)
downloadbcm5719-llvm-061d496c511b02a0c2bd394539c757c5ad4511e3.tar.gz
bcm5719-llvm-061d496c511b02a0c2bd394539c757c5ad4511e3.zip
[Coverage] Prevent detection of false instantiations in case of macro expansion.
The root of the problem was that findMainViewFileID(File, Function) could return some ID for any given file, even though that file was not the main file for that function. This patch ensures that the result of this function is conformed with the result of findMainViewFileID(Function). Differential Revision: http://reviews.llvm.org/D18787 llvm-svn: 266436
Diffstat (limited to 'llvm/test/tools/llvm-cov')
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmappingbin0 -> 318 bytes
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.cpp15
-rw-r--r--llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.proftext26
-rw-r--r--llvm/test/tools/llvm-cov/lit.local.cfg2
-rw-r--r--llvm/test/tools/llvm-cov/prevent_false_instantiations.h10
5 files changed, 52 insertions, 1 deletions
diff --git a/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping b/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping
new file mode 100644
index 00000000000..c255aa3272f
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping
Binary files differ
diff --git a/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.cpp b/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.cpp
new file mode 100644
index 00000000000..2a84f1dd58e
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.cpp
@@ -0,0 +1,15 @@
+#include "prevent_false_instantiations.h"
+
+void func1() {
+ DO_SOMETHING();
+}
+
+void func2() {
+ DO_SOMETHING();
+}
+
+int main() {
+ func1();
+ func2();
+ return 0;
+}
diff --git a/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.proftext b/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.proftext
new file mode 100644
index 00000000000..ad5362e17e4
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.proftext
@@ -0,0 +1,26 @@
+_Z5func1v
+# Func Hash:
+3
+# Num Counters:
+2
+# Counter Values:
+1
+0
+
+_Z5func2v
+# Func Hash:
+3
+# Num Counters:
+2
+# Counter Values:
+1
+0
+
+main
+# Func Hash:
+0
+# Num Counters:
+1
+# Counter Values:
+1
+
diff --git a/llvm/test/tools/llvm-cov/lit.local.cfg b/llvm/test/tools/llvm-cov/lit.local.cfg
index 05aef8645e4..8b6fe62772f 100644
--- a/llvm/test/tools/llvm-cov/lit.local.cfg
+++ b/llvm/test/tools/llvm-cov/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.test', '.m', '.cpp', '.c']
+config.suffixes = ['.test', '.m', '.cpp', '.c', '.h']
diff --git a/llvm/test/tools/llvm-cov/prevent_false_instantiations.h b/llvm/test/tools/llvm-cov/prevent_false_instantiations.h
new file mode 100644
index 00000000000..667ebde6d16
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/prevent_false_instantiations.h
@@ -0,0 +1,10 @@
+// Checks that function instantiations don't go to a wrong file.
+
+// CHECK-NOT: {{_Z5func[1,2]v}}
+
+// RUN: llvm-profdata merge %S/Inputs/prevent_false_instantiations.proftext -o %t.profdata
+// RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck %s
+
+#define DO_SOMETHING() \
+ do { \
+ } while (0)
OpenPOWER on IntegriCloud