Skip to content

Commit 64800d5

Browse files
author
Amritpan Kaur
committed
[Constraint] Pass solverState indents to ASTPrinter's dump so that AST printed during conjunction attempts are indented correctly.
1 parent 7452fc9 commit 64800d5

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

Diff for: include/swift/Sema/Constraint.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,8 @@ class Constraint final : public llvm::ilist_node<Constraint>,
855855
/// Print constraint placed on type and constraint properties.
856856
///
857857
/// \c skipLocator skips printing of locators.
858-
void print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocator = false) const;
858+
void print(llvm::raw_ostream &Out, SourceManager *sm, unsigned indent = 0,
859+
bool skipLocator = false) const;
859860

860861
SWIFT_DEBUG_DUMPER(dump(SourceManager *SM));
861862

Diff for: include/swift/Sema/ConstraintSystem.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -6107,7 +6107,7 @@ class DisjunctionChoice {
61076107
bool isSymmetricOperator() const;
61086108
bool isUnaryOperator() const;
61096109

6110-
void print(llvm::raw_ostream &Out, SourceManager *SM) const {
6110+
void print(llvm::raw_ostream &Out, SourceManager *SM, unsigned indent = 0) const {
61116111
Out << "disjunction choice ";
61126112
Choice->print(Out, SM);
61136113
}
@@ -6139,9 +6139,9 @@ class ConjunctionElement {
61396139

61406140
ConstraintLocator *getLocator() const { return Element->getLocator(); }
61416141

6142-
void print(llvm::raw_ostream &Out, SourceManager *SM) const {
6142+
void print(llvm::raw_ostream &Out, SourceManager *SM, unsigned indent) const {
61436143
Out << "conjunction element ";
6144-
Element->print(Out, SM);
6144+
Element->print(Out, SM, indent);
61456145
}
61466146

61476147
private:
@@ -6176,7 +6176,7 @@ class TypeVariableBinding {
61766176
Optional<std::pair<ConstraintFix *, unsigned>>
61776177
fixForHole(ConstraintSystem &cs) const;
61786178

6179-
void print(llvm::raw_ostream &Out, SourceManager *) const {
6179+
void print(llvm::raw_ostream &Out, SourceManager *, unsigned indent) const {
61806180
PrintOptions PO;
61816181
PO.PrintTypesForDebugging = true;
61826182
Out << "type variable " << TypeVar->getString(PO)

Diff for: lib/Sema/CSStep.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ template <typename P> class BindingStep : public SolverStep {
519519
if (CS.isDebugMode()) {
520520
auto &log = getDebugLogger();
521521
log << "(attempting ";
522-
choice->print(log, &CS.getASTContext().SourceMgr);
522+
choice->print(log, &CS.getASTContext().SourceMgr, CS.solverState->depth * 2 + 2);
523523
log << '\n';
524524
}
525525

Diff for: lib/Sema/Constraint.cpp

+3-3
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, bool skipLocator) const {
325+
void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, unsigned indent, bool skipLocator) const {
326326
// Print all type variables as $T0 instead of _ here.
327327
PrintOptions PO;
328328
PO.PrintTypesForDebugging = true;
@@ -383,11 +383,11 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, bool skipLocat
383383
Out << "pattern binding element @ ";
384384
Out << patternBindingElt->getIndex() << " : ";
385385
Out << '\n';
386-
patternBinding->getPattern(patternBindingElt->getIndex())->dump(Out);
386+
patternBinding->getPattern(patternBindingElt->getIndex())->dump(Out, indent);
387387
} else {
388388
Out << "syntactic element ";
389389
Out << '\n';
390-
element.dump(Out);
390+
element.dump(Out, indent);
391391
}
392392

393393
return;

0 commit comments

Comments
 (0)