]> granicus.if.org Git - clang/commitdiff
[Coverage] End deferred regions before labels, fixes PR35867
authorVedant Kumar <vsk@apple.com>
Fri, 1 Jun 2018 00:37:13 +0000 (00:37 +0000)
committerVedant Kumar <vsk@apple.com>
Fri, 1 Jun 2018 00:37:13 +0000 (00:37 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333715 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CoverageMappingGen.cpp
test/CoverageMapping/label.cpp

index 8f1f3d169f05c8b31fb3281abecb72c323b59308..2d8446463594289e598c9cdfaea5f9583deae5dd 100644 (file)
@@ -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);
index 7bb11993bc2880a5af9f810dc497ac8e13c2c78c..71bb8a3edfccf49670e6a698a557b62f854478a6 100644 (file)
@@ -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]]
+}