File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -1076,10 +1076,14 @@ struct CoverageMapping : public ASTWalker {
1076
1076
pushRegion (E);
1077
1077
}
1078
1078
1079
- if (auto *IE = dyn_cast<IfExpr>(E)) {
1080
- CounterExpr &ThenCounter = assignCounter (IE->getThenExpr ());
1081
- assignCounter (IE->getElseExpr (),
1082
- CounterExpr::Sub (getCurrentCounter (), ThenCounter));
1079
+ // If there isn't an active region, we may be visiting a default
1080
+ // initializer for a function argument.
1081
+ if (!RegionStack.empty ()) {
1082
+ if (auto *IE = dyn_cast<IfExpr>(E)) {
1083
+ CounterExpr &ThenCounter = assignCounter (IE->getThenExpr ());
1084
+ assignCounter (IE->getElseExpr (),
1085
+ CounterExpr::Sub (getCurrentCounter (), ThenCounter));
1086
+ }
1083
1087
}
1084
1088
1085
1089
if (hasCounter (E) && !Parent.isNull ())
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_arg_ternary %s | %FileCheck %s
2
+
3
+ var s : String ?
4
+
5
+ // CHECK: sil_coverage_map {{.*}} "$s20coverage_arg_ternary1f0B0ySSSg_tF"
6
+ // CHECK-NEXT: [[@LINE+2]]:43 -> [[@LINE+2]]:45 : 0
7
+ // CHECK-NEXT: }
8
+ func f( arg: String ? = s != nil ? s : nil ) { }
You can’t perform that action at this time.
0 commit comments