File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -349,7 +349,8 @@ struct CoverageMapping : public ASTWalker {
349
349
CounterExpr *JumpsToLabel = nullptr ;
350
350
Stmt *ParentStmt = Parent.getAsStmt ();
351
351
if (ParentStmt) {
352
- if (isa<DoCatchStmt>(ParentStmt) || isa<CatchStmt>(ParentStmt))
352
+ if (isa<DoStmt>(ParentStmt) || isa<DoCatchStmt>(ParentStmt) ||
353
+ isa<CatchStmt>(ParentStmt))
353
354
return ;
354
355
if (auto *LS = dyn_cast<LabeledStmt>(ParentStmt))
355
356
JumpsToLabel = &getCounter (LS);
@@ -530,6 +531,10 @@ struct CoverageMapping : public ASTWalker {
530
531
} else if (isa<CaseStmt>(S)) {
531
532
pushRegion (S);
532
533
534
+ } else if (auto *DS = dyn_cast<DoStmt>(S)) {
535
+ assignCounter (DS->getBody (), CounterExpr::Ref (getCurrentCounter ()));
536
+ assignCounter (DS);
537
+
533
538
} else if (auto *DCS = dyn_cast<DoCatchStmt>(S)) {
534
539
assignCounter (DCS->getBody (), CounterExpr::Ref (getCurrentCounter ()));
535
540
assignCounter (DCS);
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -Xllvm -sil-full-demangle -suppress-warnings -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_label %s | FileCheck %s
2
+
3
+ // CHECK-LABEL: sil_coverage_map {{.*}}// coverage_label.foo
4
+ func foo( ) { // CHECK-DAG: [[@LINE]]:12 -> [[@LINE+19]]:2 : 0
5
+ var x : Int32 = 0
6
+
7
+ label1: do { // CHECK-DAG: [[@LINE]]:14 -> [[@LINE+4]]:4 : 0
8
+ x += 1
9
+ break label1
10
+ x += 2 // CHECK-DAG: [[@LINE]]:5 -> [[@LINE+1]]:4 : zero
11
+ }
12
+
13
+ label2: do { // CHECK-DAG: [[@LINE]]:14 -> [[@LINE+7]]:4 : 0
14
+ x += 3 // CHECK-DAG: [[@LINE+1]]:11 -> [[@LINE+1]]:17 : 0
15
+ while ( true ) { // CHECK-DAG: [[@LINE]]:18 -> [[@LINE+3]]:6 : 1
16
+ x += 4
17
+ break label2 // Note: This exit affects the condition counter expr @ L15.
18
+ } // CHECK-DAG: [[@LINE]]:6 -> [[@LINE+2]]:4 : (0 - 1)
19
+ x += 5
20
+ }
21
+
22
+ x += 6
23
+ }
24
+
25
+ foo ( )
You can’t perform that action at this time.
0 commit comments