]> granicus.if.org Git - clang/commitdiff
Coverage mapping: fix mapping for objective-c for statement
authorAlex Lorenz <arphaman@gmail.com>
Wed, 20 Aug 2014 17:11:53 +0000 (17:11 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 20 Aug 2014 17:11:53 +0000 (17:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216082 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CoverageMappingGen.cpp
test/CoverageMapping/objc.m

index 4c5f375116781d8405ae2d9d3c46ee7df4e00b3b..86e2be8fbe283457c7f8bb0efc6cb00c5bf4bbf1 100644 (file)
@@ -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();
index e14caa9bdb77a050b51b4b113c7b947b20992a98..b41ab94ccf26ceb2e5c8603e76d17a8df0f5da4e 100644 (file)
@@ -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;
+}