Author: vedantk Date: Thu May 31 17:37:13 2018 New Revision: 333715 URL: http://llvm.org/viewvc/llvm-project?rev=333715&view=rev Log: [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. Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp cfe/trunk/test/CoverageMapping/label.cpp Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=333715&r1=333714&r2=333715&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original) +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu May 31 17:37:13 2018 @@ -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); Modified: cfe/trunk/test/CoverageMapping/label.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/label.cpp?rev=333715&r1=333714&r2=333715&view=diff ============================================================================== --- cfe/trunk/test/CoverageMapping/label.cpp (original) +++ cfe/trunk/test/CoverageMapping/label.cpp Thu May 31 17:37:13 2018 @@ -69,3 +69,12 @@ int main() { // CHECK-NE 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]] +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits