From: Vedant Kumar Date: Fri, 1 Jun 2018 00:37:13 +0000 (+0000) Subject: [Coverage] End deferred regions before labels, fixes PR35867 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d54ac86ec8fdf6e9120dcde3650c05137c67596;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333715 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CoverageMappingGen.cpp b/lib/CodeGen/CoverageMappingGen.cpp index 8f1f3d169f..2d84464635 100644 --- a/lib/CodeGen/CoverageMappingGen.cpp +++ b/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/test/CoverageMapping/label.cpp b/test/CoverageMapping/label.cpp index 7bb11993bc..71bb8a3edf 100644 --- a/test/CoverageMapping/label.cpp +++ b/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]] +}