Skip to content

Commit f3dd7f6

Browse files
author
Amritpan Kaur
committed
[Constraint] Eliminate repetitive locators to make useful information easier to read.
1 parent f13a521 commit f3dd7f6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

include/swift/Sema/Constraint.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,10 @@ class Constraint final : public llvm::ilist_node<Constraint>,
852852
/// Clone the given constraint.
853853
Constraint *clone(ConstraintSystem &cs) const;
854854

855-
void print(llvm::raw_ostream &Out, SourceManager *sm) const;
855+
/// Print constraint placed on type and constraint properties.
856+
///
857+
/// \c skipLocator skips printing of locators.
858+
void print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocator = false) const;
856859

857860
SWIFT_DEBUG_DUMPER(dump(SourceManager *SM));
858861

lib/Sema/Constraint.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ Constraint *Constraint::clone(ConstraintSystem &cs) const {
322322
llvm_unreachable("Unhandled ConstraintKind in switch.");
323323
}
324324

325-
void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm) const {
325+
void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocator) const {
326326
// Print all type variables as $T0 instead of _ here.
327327
PrintOptions PO;
328328
PO.PrintTypesForDebugging = true;
@@ -352,7 +352,8 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm) const {
352352
Out << "> [favored] ";
353353
else
354354
Out << "> ";
355-
constraint->print(Out, sm);
355+
constraint->print(Out, sm,
356+
/*skipLocator=*/constraint->getLocator() == Locator);
356357
},
357358
[&] { Out << "\n"; });
358359
return;
@@ -522,7 +523,7 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm) const {
522523
fix->print(Out);
523524
}
524525

525-
if (Locator) {
526+
if (Locator && !skipLocator) {
526527
Out << " [[";
527528
Locator->dump(sm, Out);
528529
Out << "]];";

0 commit comments

Comments
 (0)