summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-06-01 00:37:13 +0000
committerVedant Kumar <vsk@apple.com>2018-06-01 00:37:13 +0000
commitd781d97ed45259809bc19d97a77fde508e2a036d (patch)
tree1a1d76de037f22a023c52c6a8395121c7ee466bb
parent0179c6d0e5d2eff4b0073514a766bab44ba917fb (diff)
downloadbcm5719-llvm-d781d97ed45259809bc19d97a77fde508e2a036d.tar.gz
bcm5719-llvm-d781d97ed45259809bc19d97a77fde508e2a036d.zip
[Coverage] End deferred regions before labels, fixes PR35867
A deferred region should end before the start of a label, and should not extend to the start of the label sub-statement. Fixes llvm.org/PR35867. llvm-svn: 333715
-rw-r--r--clang/lib/CodeGen/CoverageMappingGen.cpp1
-rw-r--r--clang/test/CoverageMapping/label.cpp9
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 8f1f3d169f0..2d844646359 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -872,6 +872,7 @@ struct CounterCoverageMappingBuilder
Counter LabelCount = getRegionCounter(S);
SourceLocation Start = getStart(S);
completeTopLevelDeferredRegion(LabelCount, Start);
+ completeDeferred(LabelCount, Start);
// We can't extendRegion here or we risk overlapping with our new region.
handleFileExit(Start);
pushRegion(LabelCount, Start);
diff --git a/clang/test/CoverageMapping/label.cpp b/clang/test/CoverageMapping/label.cpp
index 7bb11993bc2..71bb8a3edfc 100644
--- a/clang/test/CoverageMapping/label.cpp
+++ b/clang/test/CoverageMapping/label.cpp
@@ -69,3 +69,12 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2
test1(0);
test2(2);
}
+
+// CHECK-LABEL: _Z5test3v:
+#define a b
+void test3() {
+ if (0)
+ goto b; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+1]]:1 = [[retnCount:#[0-9]+]]
+a: // CHECK-NEXT: Expansion,File 0, [[@LINE]]:1 -> [[@LINE]]:2 = [[retnCount]] (Expanded file = 1)
+ return; // CHECK-NEXT: File 0, [[@LINE-1]]:2 -> [[@LINE]]:9 = [[retnCount]]
+}
OpenPOWER on IntegriCloud