diff options
| -rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.cpp | 1 | ||||
| -rw-r--r-- | clang/test/CoverageMapping/objc.m | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 4c5f3751167..86e2be8fbe2 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -836,6 +836,7 @@ struct CounterCoverageMappingBuilder // Counter tracks the body of the loop. RegionMapper Cnt(this, S); BreakContinueStack.push_back(BreakContinue()); + Cnt.beginRegion(); VisitSubStmtRBraceState(S->getBody()); BreakContinue BC = BreakContinueStack.pop_back_val(); Cnt.adjustForControlFlow(); diff --git a/clang/test/CoverageMapping/objc.m b/clang/test/CoverageMapping/objc.m index e14caa9bdb7..b41ab94ccf2 100644 --- a/clang/test/CoverageMapping/objc.m +++ b/clang/test/CoverageMapping/objc.m @@ -9,3 +9,21 @@ void func(A *a) { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:2 = #0 if (a) [a bork: 20 ]; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:20 = #1 (HasCodeBefore = 0) } + +@interface NSArray ++ (NSArray*) arrayWithObjects: (id) first, ...; +- (unsigned) count; +@end + + // CHECK: func2 +void func2(NSArray *array) { // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+10]]:2 = #0 (HasCodeBefore = 0) + int i = 0; + for (NSArray *x in array) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+6]]:4 = #1 (HasCodeBefore = 0) + if (x) { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = #2 (HasCodeBefore = 0) + i = 1; + } else { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = (#1 - #2) (HasCodeBefore = 0) + i = -1; + } + } + i = 0; +} |

