Skip to content

Commit 82ac932

Browse files
committed
[NFC] CS: Misc minor debug output tweaks
* Use fancy arrows (`→`) because they are distinct from and shorter than `->`, and fancier. * We have two ways of demarcating locators: `@ <locator>` and `[[<locator>]];`. Stick to the first, which is shorter and clearer. * 'attempting type variable' → 'attempting binding'. *Bindings* are attempted, not type variables. * `considering ->` → `considering:`. I think a colon is semantically more fit and makes things easier to read if the considered constraint has arrows in its description or types. It’s also shorter this way.
1 parent c1d5118 commit 82ac932

10 files changed

+28
-29
lines changed

docs/DebuggingTheCompiler.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ constraints and present the final type checked solution, e.g.:
164164

165165
```
166166
---Constraint solving at [test.swift:3:1 - line:3:1]---
167+
167168
---Initial constraints for the given expression---
168169
(integer_literal_expr type='$T0' location=test.swift:3:1 range=[test.swift:3:1 - line:3:1] value=0 builtin_initializer=**NULL** initializer=**NULL**)
169170
@@ -172,14 +173,14 @@ Type Variables:
172173
($T0 [attributes: [literal: integer]] [with possible bindings: (default type of literal) Int]) @ locator@0x13e009800 [IntegerLiteral@test.swift:3:1]
173174
174175
Inactive Constraints:
175-
$T0 literal conforms to ExpressibleByIntegerLiteral [[locator@0x13e009800 [IntegerLiteral@test.swift:3:1]]];
176+
$T0 literal conforms to ExpressibleByIntegerLiteral @ locator@0x13e009800 [IntegerLiteral@test.swift:3:1]
176177
177178
(Potential Binding(s):
178179
($T0 [attributes: [literal: integer]] [with possible bindings: (default type of literal) Int])
179180
(attempting type variable $T0 := Int
180-
(considering -> $T0 literal conforms to ExpressibleByIntegerLiteral [[locator@0x13e009800 [IntegerLiteral@test.swift:3:1]]];
181+
(considering: $T0 literal conforms to ExpressibleByIntegerLiteral @ locator@0x13e009800 [IntegerLiteral@test.swift:3:1]
181182
(simplification result:
182-
(removed constraint: $T0 literal conforms to ExpressibleByIntegerLiteral [[locator@0x13e009800 [IntegerLiteral@test.swift:3:1]]];)
183+
(removed constraint: $T0 literal conforms to ExpressibleByIntegerLiteral @ locator@0x13e009800 [IntegerLiteral@test.swift:3:1])
183184
)
184185
(outcome: simplified)
185186
)
@@ -188,7 +189,7 @@ Inactive Constraints:
188189
> $T0 := Int
189190
)
190191
(Removed Constraint:
191-
> $T0 literal conforms to ExpressibleByIntegerLiteral [[locator@0x13e009800 [IntegerLiteral@test.swift:3:1]]];
192+
> $T0 literal conforms to ExpressibleByIntegerLiteral @ locator@0x13e009800 [IntegerLiteral@test.swift:3:1]
192193
)
193194
)
194195
(found solution: <default 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0>)

include/swift/Sema/ConstraintSystem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5765,7 +5765,7 @@ class TypeVariableBinding {
57655765
void print(llvm::raw_ostream &Out, SourceManager *, unsigned indent) const {
57665766
PrintOptions PO;
57675767
PO.PrintTypesForDebugging = true;
5768-
Out << "type variable " << TypeVar->getString(PO)
5768+
Out << "type variable binding " << TypeVar->getString(PO)
57695769
<< " := " << Binding.BindingType->getString(PO);
57705770
}
57715771
};

lib/Sema/CSGen.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4604,7 +4604,7 @@ bool ConstraintSystem::generateConstraints(
46044604

46054605
if (isDebugMode()) {
46064606
auto &log = llvm::errs();
4607-
log << "---Initial constraints for the given expression---\n";
4607+
log << "\n---Initial constraints for the given expression---\n";
46084608
print(log, expr);
46094609
log << "\n";
46104610
print(log);

lib/Sema/CSSolver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ bool ConstraintSystem::simplify() {
369369
if (isDebugMode()) {
370370
auto &log = llvm::errs();
371371
log.indent(solverState->getCurrentIndent());
372-
log << "(considering -> ";
372+
log << "(considering: ";
373373
constraint->print(log, &getASTContext().SourceMgr,
374374
solverState->getCurrentIndent());
375375
log << "\n";
@@ -1485,7 +1485,7 @@ ConstraintSystem::solveImpl(SyntacticElementTarget &target,
14851485
FreeTypeVariableBinding allowFreeTypeVariables) {
14861486
if (isDebugMode()) {
14871487
auto &log = llvm::errs();
1488-
log << "---Constraint solving at ";
1488+
log << "\n---Constraint solving at ";
14891489
auto R = target.getSourceRange();
14901490
if (R.isValid()) {
14911491
R.print(log, getASTContext().SourceMgr, /*PrintText=*/ false);

lib/Sema/Constraint.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,8 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm,
380380
Out << " (isolated)";
381381

382382
if (Locator) {
383-
Out << " [[";
383+
Out << " @ ";
384384
Locator->dump(sm, Out);
385-
Out << "]]";
386385
}
387386
Out << ":\n";
388387

@@ -479,15 +478,15 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm,
479478
case ConstraintKind::KeyPath:
480479
Out << " key path from ";
481480
Out << getSecondType()->getString(PO);
482-
Out << " -> ";
481+
Out << " ";
483482
Out << getThirdType()->getString(PO);
484483
skipSecond = true;
485484
break;
486485

487486
case ConstraintKind::KeyPathApplication:
488487
Out << " key path projecting ";
489488
Out << getSecondType()->getString(PO);
490-
Out << " -> ";
489+
Out << " ";
491490
Out << getThirdType()->getString(PO);
492491
skipSecond = true;
493492
break;
@@ -608,9 +607,8 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm,
608607
}
609608

610609
if (Locator && !skipLocator) {
611-
Out << " [[";
610+
Out << " @ ";
612611
Locator->dump(sm, Out);
613-
Out << "]];";
614612
}
615613
}
616614

lib/Sema/ConstraintLocator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) const {
707707
constraints::dumpAnchor(anchor, sm, out);
708708

709709
for (auto elt : getPath()) {
710-
out << " -> ";
710+
out << " ";
711711
elt.dump(out);
712712
}
713713
out << ']';

test/Concurrency/async_overload_filtering.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var a: String? = nil
1919
// CHECK: attempting disjunction choice $T0 bound to decl async_overload_filtering.(file).filter_async(fn2:)
2020
// CHECK-NEXT: added constraint: {{.*}} conforms to _Copyable
2121
// CHECK-NEXT: overload set choice binding $T0 := {{.*}}
22-
// CHECK-NEXT: (considering -> ({{.*}}) -> {{.*}} applicable fn {{.*}}
22+
// CHECK-NEXT: (considering: ({{.*}}) -> {{.*}} applicable fn {{.*}}
2323
// CHECK: increasing 'sync-in-asynchronous' score by 1
2424
// CHECK: solution is worse than the best solution
2525
filter_async {

test/Constraints/common_type.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ func f(_: Double) -> Y { return Y() }
2828

2929
func testCallCommonType() {
3030
// CHECK: overload set choice binding $T{{[0-9]+}} := (Int) -> X
31-
// CHECK: (considering -> $T{{[0-9]+}}[.g: value] == [[G:\$T[0-9]+]]
31+
// CHECK: (considering: $T{{[0-9]+}}[.g: value] == [[G:\$T[0-9]+]]
3232
// CHECK: (common result type for [[G]] is Int)
3333
// CHECK: (overload set choice binding $T{{[0-9]+}} := (Double) -> Y)
34-
// CHECK: (considering -> $T{{[0-9]+}}[.g: value] == [[F:\$T[0-9]+]]
34+
// CHECK: (considering: $T{{[0-9]+}}[.g: value] == [[F:\$T[0-9]+]]
3535
// CHECK: (common result type for [[F]] is Double)
3636
_ = f(0).g(0)
3737
}

test/Constraints/one_way_solve.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ func testTernaryOneWayOverload(b: Bool) {
2828
// CHECK: 0: $T{{[0-9]+}} $T{{[0-9]+}} $T{{[0-9]+}}
2929

3030
// CHECK: solving component #1
31-
// CHECK: (attempting type variable [[C]] := Int8
31+
// CHECK: (attempting type variable binding [[C]] := Int8
3232

3333
// CHECK: solving component #1
34-
// CHECK: (attempting type variable [[C]] := Int8
34+
// CHECK: (attempting type variable binding [[C]] := Int8
3535

3636
// CHECK: solving component #1
37-
// CHECK: (attempting type variable [[C]] := Int8
37+
// CHECK: (attempting type variable binding [[C]] := Int8
3838

3939
// CHECK: solving component #1
40-
// CHECK: (attempting type variable [[C]] := Int8
41-
// CHECK: (considering -> $T{{[0-9]+}} conv [[C]]
42-
// CHECK: (considering -> $T{{[0-9]+}} conv [[C]]
43-
// CHECK: (considering -> [[C]] conv Int8
40+
// CHECK: (attempting type variable binding [[C]] := Int8
41+
// CHECK: (considering: $T{{[0-9]+}} conv [[C]]
42+
// CHECK: (considering: $T{{[0-9]+}} conv [[C]]
43+
// CHECK: (considering: [[C]] conv Int8
4444
// CHECK: (found solution: [component: non-default literal(s), value: 2] [component: use of overloaded unapplied function(s), value: 2])
4545

4646
// CHECK: (composed solution: [component: non-default literal(s), value: 2] [component: use of overloaded unapplied function(s), value: 2])

test/Constraints/result_builder_conjunction_selection.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ do {
3333

3434
// CHECK: ---Initial constraints for the given expression---
3535
// CHECK: (integer_literal_expr type='[[LITERAL_VAR:\$T[0-9]+]]' {{.*}}
36-
// CHECK: (attempting type variable [[CLOSURE:\$T[0-9]+]] := () -> {{.*}}
37-
// CHECK-NOT: (attempting type variable [[LITERAL_VAR]] := {{.*}}
36+
// CHECK: (attempting type variable binding [[CLOSURE:\$T[0-9]+]] := () -> {{.*}}
37+
// CHECK-NOT: (attempting type variable binding [[LITERAL_VAR]] := {{.*}}
3838
// CHECK: (attempting conjunction element pattern binding element @ 0
3939
// CHECK: (applying conjunction result to outer context
40-
// CHECK: (attempting type variable [[LITERAL_VAR]] := Int
40+
// CHECK: (attempting type variable binding [[LITERAL_VAR]] := Int
4141
test(42) {
4242
1
4343
""
@@ -49,7 +49,7 @@ do {
4949

5050
// CHECK: ---Initial constraints for the given expression---
5151
// CHECK: (integer_literal_expr type='[[LITERAL_VAR:\$T[0-9]+]]' {{.*}}
52-
// CHECK: (attempting type variable [[LITERAL_VAR]] := Int
52+
// CHECK: (attempting type variable binding [[LITERAL_VAR]] := Int
5353
// CHECK: (attempting conjunction element pattern binding element @ 0
5454
test(42) { v in
5555
v

0 commit comments

Comments
 (0)