Improve indentation in debugging output

This commit is contained in:
Timofey Solonin
2022-11-17 23:06:13 +08:00
parent 3c401a1c7e
commit 3f366947e4
11 changed files with 167 additions and 128 deletions

View File

@@ -1708,7 +1708,7 @@ public:
SWIFT_DEBUG_DUMP;
/// Dump this solution.
void dump(raw_ostream &OS) const LLVM_ATTRIBUTE_USED;
void dump(raw_ostream &OS, unsigned indent) const LLVM_ATTRIBUTE_USED;
};
/// Describes the differences between several solutions to the same
@@ -6433,9 +6433,10 @@ public:
bool isSymmetricOperator() const;
bool isUnaryOperator() const;
void print(llvm::raw_ostream &Out, SourceManager *SM, unsigned indent = 0) const {
void print(llvm::raw_ostream &Out, SourceManager *SM,
unsigned indent = 0) const {
Out << "disjunction choice ";
Choice->print(Out, SM);
Choice->print(Out, SM, indent);
}
operator Constraint *() { return Choice; }

View File

@@ -2370,9 +2370,10 @@ Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
}
if (cs.isDebugMode()) {
auto &log = llvm::errs();
auto indent = cs.solverState ? cs.solverState->getCurrentIndent() : 0;
auto &log = llvm::errs().indent(indent);
log << "--- Applying Solution ---\n";
solutions.front().dump(log);
solutions.front().dump(log, indent);
log << '\n';
}
@@ -2387,7 +2388,8 @@ Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
auto *body = result->getFunctionBody();
if (cs.isDebugMode()) {
auto &log = llvm::errs();
auto indent = cs.solverState ? cs.solverState->getCurrentIndent() : 0;
auto &log = llvm::errs().indent(indent);
log << "--- Type-checked function body ---\n";
body->dump(log);
log << '\n';

View File

@@ -55,8 +55,8 @@ void ConstraintSystem::increaseScore(ScoreKind kind, unsigned value) {
if (isDebugMode() && value > 0) {
if (solverState)
llvm::errs().indent(solverState->getCurrentIndent());
llvm::errs() << "(increasing '" << Score::getNameFor(kind) << "' score by " << value
<< ")\n";
llvm::errs() << "(increasing '" << Score::getNameFor(kind) << "' score by "
<< value << ")\n";
}
unsigned index = static_cast<unsigned>(kind);
@@ -804,7 +804,7 @@ SolutionCompareResult ConstraintSystem::compareSolutions(
const SolutionDiff &diff, unsigned idx1, unsigned idx2) {
if (cs.isDebugMode()) {
llvm::errs().indent(cs.solverState->getCurrentIndent())
<< "comparing solutions " << idx1 << " and " << idx2 <<"\n";
<< "comparing solutions " << idx1 << " and " << idx2 << "\n";
}
// Whether the solutions are identical.
@@ -1360,13 +1360,15 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
return 0;
if (isDebugMode()) {
llvm::errs().indent(solverState->getCurrentIndent())
<< "Comparing " << viable.size() << " viable solutions\n";
auto indent = solverState->getCurrentIndent();
auto &log = llvm::errs();
log.indent(indent) << "Comparing " << viable.size()
<< " viable solutions\n";
for (unsigned i = 0, n = viable.size(); i != n; ++i) {
llvm::errs().indent(solverState->getCurrentIndent())
<< "\n--- Solution #" << i << " ---\n";
viable[i].dump(llvm::errs().indent(solverState->getCurrentIndent()));
log << "\n";
log.indent(indent) << "--- Solution #" << i << " ---\n";
viable[i].dump(llvm::errs(), indent);
}
}

View File

@@ -361,7 +361,8 @@ bool ConstraintSystem::simplify() {
auto &log = llvm::errs();
log.indent(solverState->getCurrentIndent());
log << "(considering -> ";
constraint->print(log, &getASTContext().SourceMgr);
constraint->print(log, &getASTContext().SourceMgr,
solverState->getCurrentIndent());
log << "\n";
// {Dis, Con}junction are returned unsolved in \c simplifyConstraint() and
@@ -498,7 +499,8 @@ ConstraintSystem::SolverState::SolverState(
if (tyOpts.DebugConstraintSolverAttempt &&
tyOpts.DebugConstraintSolverAttempt == SolutionAttempt) {
CS.Options |= ConstraintSystemFlags::DebugConstraints;
llvm::errs() << "---Constraint system #" << SolutionAttempt << "---\n";
llvm::errs().indent(CS.solverState->getCurrentIndent())
<< "---Constraint system #" << SolutionAttempt << "---\n";
CS.print(llvm::errs());
}
}
@@ -802,7 +804,8 @@ bool ConstraintSystem::Candidate::solve(
auto &ctx = cs.getASTContext();
if (cs.isDebugMode()) {
auto &log = llvm::errs();
log << "--- Solving candidate for shrinking at ";
auto indent = cs.solverState ? cs.solverState->getCurrentIndent() : 0;
log.indent(indent) << "--- Solving candidate for shrinking at ";
auto R = E->getSourceRange();
if (R.isValid()) {
R.print(log, ctx.SourceMgr, /*PrintText=*/ false);
@@ -811,7 +814,7 @@ bool ConstraintSystem::Candidate::solve(
}
log << " ---\n";
E->dump(log);
E->dump(log, indent);
log << '\n';
cs.print(log);
}
@@ -839,14 +842,18 @@ bool ConstraintSystem::Candidate::solve(
if (cs.isDebugMode()) {
auto &log = llvm::errs();
auto indent = cs.solverState ? cs.solverState->getCurrentIndent() : 0;
if (solutions.empty()) {
log << "--- No Solutions ---\n";
log << "\n";
log.indent(indent) << "--- No Solutions ---\n";
} else {
log << "--- Solutions ---\n";
log << "\n";
log.indent(indent) << "--- Solutions ---\n";
for (unsigned i = 0, n = solutions.size(); i != n; ++i) {
auto &solution = solutions[i];
log << "\n--- Solution #" << i << " ---\n";
solution.dump(log);
log << "\n";
log.indent(indent) << "--- Solution #" << i << " ---\n";
solution.dump(log, indent);
}
}
}
@@ -1329,14 +1336,18 @@ Optional<std::vector<Solution>> ConstraintSystem::solve(
auto dumpSolutions = [&](const SolutionResult &result) {
// Debug-print the set of solutions.
if (isDebugMode()) {
auto &log = llvm::errs();
auto indent = solverState ? solverState->getCurrentIndent() : 0;
if (result.getKind() == SolutionResult::Success) {
llvm::errs() << "\n---Solution---\n";
result.getSolution().dump(llvm::errs());
log << "\n";
log.indent(indent) << "---Solution---\n";
result.getSolution().dump(llvm::errs(), indent);
} else if (result.getKind() == SolutionResult::Ambiguous) {
auto solutions = result.getAmbiguousSolutions();
for (unsigned i : indices(solutions)) {
llvm::errs() << "\n--- Solution #" << i << " ---\n";
solutions[i].dump(llvm::errs());
log << "\n";
log.indent(indent) << "--- Solution #" << i << " ---\n";
solutions[i].dump(llvm::errs(), indent);
}
}
}
@@ -1605,10 +1616,12 @@ void ConstraintSystem::solveForCodeCompletion(
if (isDebugMode()) {
auto &log = llvm::errs();
log << "--- Discovered " << solutions.size() << " solutions ---\n";
auto indent = solverState ? solverState->getCurrentIndent() : 0;
log.indent(indent) << "--- Discovered " << solutions.size()
<< " solutions ---\n";
for (const auto &solution : solutions) {
log << "--- Solution ---\n";
solution.dump(log);
log.indent(indent) << "--- Solution ---\n";
solution.dump(log, indent);
}
}
@@ -1630,7 +1643,8 @@ bool ConstraintSystem::solveForCodeCompletion(
if (isDebugMode()) {
auto &log = llvm::errs();
log << "--- Code Completion ---\n";
log.indent(solverState ? solverState->getCurrentIndent() : 0)
<< "--- Code Completion ---\n";
}
if (generateConstraints(target, FreeTypeVariableBinding::Disallow))
@@ -1674,10 +1688,10 @@ ConstraintSystem::filterDisjunction(
}
if (isDebugMode()) {
llvm::errs().indent(solverState ? solverState->getCurrentIndent() : 0)
<< "(disabled disjunction term ";
constraint->print(llvm::errs(), &ctx.SourceMgr);
llvm::errs() << ")\n";
auto indent = (solverState ? solverState->getCurrentIndent() : 0) + 4;
llvm::errs().indent(indent) << "(disabled disjunction term ";
constraint->print(llvm::errs(), &ctx.SourceMgr, indent);
llvm::errs().indent(indent) << ")\n";
}
if (restoreOnFail)
@@ -1733,10 +1747,11 @@ ConstraintSystem::filterDisjunction(
}
if (isDebugMode()) {
llvm::errs().indent(solverState ? solverState->getCurrentIndent(): 0)
auto indent = (solverState ? solverState->getCurrentIndent() : 0) + 4;
llvm::errs().indent(indent)
<< "(introducing single enabled disjunction term ";
choice->print(llvm::errs(), &ctx.SourceMgr);
llvm::errs() << ")\n";
choice->print(llvm::errs(), &ctx.SourceMgr, indent);
llvm::errs().indent(indent) << ")\n";
}
simplifyDisjunctionChoice(choice);

View File

@@ -105,13 +105,14 @@ void SplitterStep::computeFollowupSteps(
if (CS.isDebugMode()) {
auto &log = getDebugLogger();
auto indent = CS.solverState->getCurrentIndent();
// Verify that the constraint graph is valid.
CG.verify();
log << "---Constraint graph---\n";
log.indent(indent) << "---Constraint graph---\n";
CG.print(CS.getTypeVariables(), log);
log << "---Connected components---\n";
log.indent(indent) << "---Connected components---\n";
CG.printConnectedComponents(CS.getTypeVariables(), log);
}
@@ -382,7 +383,7 @@ StepResult ComponentStep::take(bool prevFailed) {
if (!overloadDisjunctions.empty()) {
auto &log = getDebugLogger();
log.indent(2);
log.indent(CS.solverState->getCurrentIndent() + 2);
log << "Disjunction(s) = [";
interleave(overloadDisjunctions, log, ", ");
log << "]\n";
@@ -429,7 +430,9 @@ StepResult ComponentStep::take(bool prevFailed) {
auto printConstraints = [&](const ConstraintList &constraints) {
for (auto &constraint : constraints)
constraint.print(getDebugLogger(), &CS.getASTContext().SourceMgr);
constraint.print(
getDebugLogger().indent(CS.solverState->getCurrentIndent()),
&CS.getASTContext().SourceMgr, CS.solverState->getCurrentIndent());
};
// If we don't have any disjunction or type variable choices left, we're done
@@ -671,7 +674,7 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
if (CS.isDebugMode()) {
auto &log = getDebugLogger();
log << "(skipping " + reason + " ";
choice.print(log, &ctx.SourceMgr);
choice.print(log, &ctx.SourceMgr, CS.solverState->getCurrentIndent());
log << ")\n";
}

View File

@@ -707,7 +707,8 @@ public:
void print(llvm::raw_ostream &Out) override {
Out << "DisjunctionStep for ";
Disjunction->print(Out, &CS.getASTContext().SourceMgr);
Disjunction->print(Out, &CS.getASTContext().SourceMgr,
CS.solverState->getCurrentIndent());
Out << '\n';
}
@@ -1013,7 +1014,8 @@ public:
void print(llvm::raw_ostream &Out) override {
Out << "ConjunctionStep for ";
Conjunction->print(Out, &CS.getASTContext().SourceMgr);
Conjunction->print(Out, &CS.getASTContext().SourceMgr,
CS.solverState->getCurrentIndent());
Out << '\n';
}

View File

@@ -360,7 +360,8 @@ Constraint *Constraint::clone(ConstraintSystem &cs) const {
llvm_unreachable("Unhandled ConstraintKind in switch.");
}
void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, unsigned indent, bool skipLocator) const {
void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm,
unsigned indent, bool skipLocator) const {
// Print all type variables as $T0 instead of _ here.
PrintOptions PO;
PO.PrintTypesForDebugging = true;
@@ -395,9 +396,10 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, unsigned inden
return false;
});
interleave(sortedConstraints,
interleave(
sortedConstraints,
[&](Constraint *constraint) {
Out.indent(indent);
Out.indent(indent + 2);
if (constraint->isDisabled())
Out << "> [disabled] ";
else if (constraint->isFavored())
@@ -405,7 +407,8 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm, unsigned inden
else
Out << "> ";
constraint->print(Out, sm, indent,
/*skipLocator=*/constraint->getLocator() == Locator);
/*skipLocator=*/constraint->getLocator() ==
Locator);
},
[&] { Out << "\n"; });
return;

View File

@@ -1438,12 +1438,12 @@ bool ConstraintGraph::contractEdges() {
auto rep2 = CS.getRepresentative(tyvar2);
if (CS.isDebugMode()) {
auto &log = llvm::errs();
if (CS.solverState)
log.indent(CS.solverState->getCurrentIndent());
auto indent = CS.solverState ? CS.solverState->getCurrentIndent() : 0;
auto &log = llvm::errs().indent(indent);
log << "Contracting constraint ";
constraint->print(log, &CS.getASTContext().SourceMgr);
constraint->print(log.indent(indent), &CS.getASTContext().SourceMgr,
indent);
log << "\n";
}
@@ -1488,7 +1488,7 @@ void ConstraintGraphNode::print(llvm::raw_ostream &out, unsigned indent,
for (auto constraint : sortedConstraints) {
out.indent(indent + 4);
constraint->print(out, &TypeVar->getASTContext().SourceMgr);
constraint->print(out, &TypeVar->getASTContext().SourceMgr, indent + 4);
out << "\n";
}
}
@@ -1545,7 +1545,8 @@ void ConstraintGraph::print(ArrayRef<TypeVariableType *> typeVars,
PO.PrintTypesForDebugging = true;
for (auto typeVar : typeVars) {
(*this)[typeVar].print(out, 2, PO);
(*this)[typeVar].print(
out, (CS.solverState ? CS.solverState->getCurrentIndent() : 0) + 2, PO);
out << "\n";
}
}
@@ -1682,7 +1683,7 @@ void ConstraintGraph::printConnectedComponents(
PrintOptions PO;
PO.PrintTypesForDebugging = true;
for (const auto& component : components) {
out.indent(2);
out.indent((CS.solverState ? CS.solverState->getCurrentIndent() : 0) + 2);
out << component.solutionIndex << ": ";
SWIFT_DEFER {
out << '\n';

View File

@@ -3958,7 +3958,7 @@ SolutionResult ConstraintSystem::salvage() {
int i = 0;
for (auto &solution : viable) {
log << "---Ambiguous solution #" << i++ << "---\n";
solution.dump(log);
solution.dump(log, solverState->getCurrentIndent());
log << "\n";
}
}
@@ -4692,13 +4692,15 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
return true;
if (isDebugMode()) {
auto &log = llvm::errs();
auto indent = solverState->getCurrentIndent();
auto &log = llvm::errs().indent(indent);
log << "--- Ambiguity: Considering #" << solutions.size()
<< " solutions with fixes ---\n";
int i = 0;
for (auto &solution : solutions) {
log << "\n--- Solution #" << i++ << "---\n";
solution.dump(log);
log << "\n";
log.indent(indent) << "--- Solution #" << i++ << "---\n";
solution.dump(log, indent);
log << "\n";
}
}

View File

@@ -410,8 +410,10 @@ getTypeOfCompletionOperatorImpl(DeclContext *DC, Expr *expr,
if (CS.isDebugMode()) {
auto &log = llvm::errs();
log << "---Initial constraints for the given expression---\n";
expr->dump(log);
auto indent = CS.solverState ? CS.solverState->getCurrentIndent() : 0;
log.indent(indent)
<< "---Initial constraints for the given expression---\n";
expr->dump(log, indent);
log << "\n";
CS.print(log);
}
@@ -424,8 +426,9 @@ getTypeOfCompletionOperatorImpl(DeclContext *DC, Expr *expr,
auto &solution = viable[0];
if (CS.isDebugMode()) {
auto &log = llvm::errs();
log << "---Solution---\n";
solution.dump(log);
auto indent = CS.solverState ? CS.solverState->getCurrentIndent() : 0;
log.indent(indent) << "---Solution---\n";
solution.dump(log, indent);
}
// Fill the results.

View File

@@ -1273,20 +1273,19 @@ void OverloadChoice::dump(Type adjustedOpenedType, SourceManager *sm,
}
}
void Solution::dump() const {
dump(llvm::errs());
}
void Solution::dump() const { dump(llvm::errs(), 0); }
void Solution::dump(raw_ostream &out) const {
void Solution::dump(raw_ostream &out, unsigned indent) const {
PrintOptions PO;
PO.PrintTypesForDebugging = true;
SourceManager *sm = &getConstraintSystem().getASTContext().SourceMgr;
out << "Fixed score:";
out.indent(indent) << "Fixed score:";
FixedScore.print(out);
out << "\nType variables:\n";
out << "\n";
out.indent(indent) << "Type variables:\n";
std::vector<std::pair<TypeVariableType *, Type>> bindings(
typeBindings.begin(), typeBindings.end());
llvm::sort(bindings, [](const std::pair<TypeVariableType *, Type> &lhs,
@@ -1295,7 +1294,7 @@ void Solution::dump(raw_ostream &out) const {
});
for (auto binding : bindings) {
auto &typeVar = binding.first;
out.indent(2);
out.indent(indent + 2);
Type(typeVar).print(out, PO);
out << " as ";
binding.second.print(out, PO);
@@ -1307,11 +1306,12 @@ void Solution::dump(raw_ostream &out) const {
}
if (!overloadChoices.empty()) {
out << "\nOverload choices:";
out << "\n";
out.indent(indent) << "Overload choices:";
for (auto ovl : overloadChoices) {
if (ovl.first) {
out << "\n";
out.indent(2);
out.indent(indent + 2);
ovl.first->dump(sm, out);
}
@@ -1323,18 +1323,18 @@ void Solution::dump(raw_ostream &out) const {
if (!ConstraintRestrictions.empty()) {
out << "\nConstraint restrictions:\n";
out.indent(indent) << "Constraint restrictions:\n";
for (auto &restriction : ConstraintRestrictions) {
out.indent(2) << restriction.first.first
<< " to " << restriction.first.second
out.indent(indent + 2)
<< restriction.first.first << " to " << restriction.first.second
<< " is " << getName(restriction.second) << "\n";
}
}
if (!argumentMatchingChoices.empty()) {
out << "\nTrailing closure matching:\n";
out.indent(indent) << "Trailing closure matching:\n";
for (auto &argumentMatching : argumentMatchingChoices) {
out.indent(2);
out.indent(indent + 2);
argumentMatching.first->dump(sm, out);
switch (argumentMatching.second.trailingClosureMatching) {
case TrailingClosureMatching::Forward:
@@ -1348,18 +1348,18 @@ void Solution::dump(raw_ostream &out) const {
}
if (!DisjunctionChoices.empty()) {
out << "\nDisjunction choices:\n";
out.indent(indent) << "Disjunction choices:\n";
for (auto &choice : DisjunctionChoices) {
out.indent(2);
out.indent(indent + 2);
choice.first->dump(sm, out);
out << " is #" << choice.second << "\n";
}
}
if (!OpenedTypes.empty()) {
out << "\nOpened types:\n";
out.indent(indent) << "Opened types:\n";
for (const auto &opened : OpenedTypes) {
out.indent(2);
out.indent(indent + 2);
opened.first->dump(sm, out);
out << " opens ";
llvm::interleave(
@@ -1391,9 +1391,9 @@ void Solution::dump(raw_ostream &out) const {
}
if (!OpenedExistentialTypes.empty()) {
out << "\nOpened existential types:\n";
out.indent(indent) << "Opened existential types:\n";
for (const auto &openedExistential : OpenedExistentialTypes) {
out.indent(2);
out.indent(indent + 2);
openedExistential.first->dump(sm, out);
out << " opens to " << openedExistential.second->getString(PO);
out << "\n";
@@ -1401,18 +1401,19 @@ void Solution::dump(raw_ostream &out) const {
}
if (!DefaultedConstraints.empty()) {
out << "\nDefaulted constraints: ";
out.indent(indent) << "Defaulted constraints: ";
interleave(DefaultedConstraints, [&](ConstraintLocator *locator) {
locator->dump(sm, out);
}, [&] {
out << ", ";
});
out << "\n";
}
if (!Fixes.empty()) {
out << "\nFixes:\n";
out.indent(indent) << "Fixes:\n";
for (auto *fix : Fixes) {
out.indent(2);
out.indent(indent + 2);
fix->print(out);
out << "\n";
}
@@ -1444,7 +1445,8 @@ void ConstraintSystem::print(raw_ostream &out, Expr *E) const {
return Type();
};
E->dump(out, getTypeOfExpr, getTypeOfTypeRepr, getTypeOfKeyPathComponent);
E->dump(out, getTypeOfExpr, getTypeOfTypeRepr, getTypeOfKeyPathComponent,
solverState ? solverState->getCurrentIndent() : 0);
out << "\n";
}
@@ -1453,13 +1455,15 @@ void ConstraintSystem::print(raw_ostream &out) const {
PrintOptions PO;
PO.PrintTypesForDebugging = true;
out << "Score:";
auto indent = solverState ? solverState->getCurrentIndent() : 0;
out.indent(indent) << "Score:";
CurrentScore.print(out);
for (const auto &contextualTypeEntry : contextualTypes) {
auto info = contextualTypeEntry.second.first;
if (!info.getType().isNull()) {
out << "\nContextual Type: " << info.getType().getString(PO);
out << "\n";
out.indent(indent) << "Contextual Type: " << info.getType().getString(PO);
if (TypeRepr *TR = info.typeLoc.getTypeRepr()) {
out << " at ";
TR->getSourceRange().print(out, getASTContext().SourceMgr, /*text*/false);
@@ -1467,7 +1471,8 @@ void ConstraintSystem::print(raw_ostream &out) const {
}
}
out << "\nType Variables:\n";
out << "\n";
out.indent(indent) << "Type Variables:\n";
std::vector<TypeVariableType *> typeVariables(getTypeVariables().begin(),
getTypeVariables().end());
llvm::sort(typeVariables,
@@ -1475,7 +1480,7 @@ void ConstraintSystem::print(raw_ostream &out) const {
return lhs->getID() < rhs->getID();
});
for (auto tv : typeVariables) {
out.indent(2);
out.indent(indent + 2);
auto rep = getRepresentative(tv);
if (rep == tv) {
if (auto fixed = getFixedType(tv)) {
@@ -1500,34 +1505,34 @@ void ConstraintSystem::print(raw_ostream &out) const {
}
if (!ActiveConstraints.empty()) {
out << "\nActive Constraints:\n";
out.indent(indent) << "Active Constraints:\n";
for (auto &constraint : ActiveConstraints) {
out.indent(2);
out.indent(indent + 2);
constraint.print(out, &getASTContext().SourceMgr);
out << "\n";
}
}
if (!InactiveConstraints.empty()) {
out << "\nInactive Constraints:\n";
out.indent(indent) << "Inactive Constraints:\n";
for (auto &constraint : InactiveConstraints) {
out.indent(2);
out.indent(indent + 2);
constraint.print(out, &getASTContext().SourceMgr);
out << "\n";
}
}
if (solverState && solverState->hasRetiredConstraints()) {
out << "\nRetired Constraints:\n";
out.indent(indent) << "Retired Constraints:\n";
solverState->forEachRetired([&](Constraint &constraint) {
out.indent(2);
out.indent(indent + 2);
constraint.print(out, &getASTContext().SourceMgr);
out << "\n";
});
}
if (!ResolvedOverloads.empty()) {
out << "\nResolved overloads:\n";
out.indent(indent) << "Resolved overloads:\n";
// Otherwise, report the resolved overloads.
for (auto elt : ResolvedOverloads) {
@@ -1570,18 +1575,18 @@ void ConstraintSystem::print(raw_ostream &out) const {
}
if (!DisjunctionChoices.empty()) {
out << "\nDisjunction choices:\n";
out.indent(indent) << "Disjunction choices:\n";
for (auto &choice : DisjunctionChoices) {
out.indent(2);
out.indent(indent + 2);
choice.first->dump(&getASTContext().SourceMgr, out);
out << " is #" << choice.second << "\n";
}
}
if (!OpenedTypes.empty()) {
out << "\nOpened types:\n";
out.indent(indent) << "Opened types:\n";
for (const auto &opened : OpenedTypes) {
out.indent(2);
out.indent(indent + 2);
opened.first->dump(&getASTContext().SourceMgr, out);
out << " opens ";
llvm::interleave(
@@ -1601,9 +1606,9 @@ void ConstraintSystem::print(raw_ostream &out) const {
}
if (!OpenedExistentialTypes.empty()) {
out << "\nOpened existential types:\n";
out.indent(indent) << "Opened existential types:\n";
for (const auto &openedExistential : OpenedExistentialTypes) {
out.indent(2);
out.indent(indent + 2);
openedExistential.first->dump(&getASTContext().SourceMgr, out);
out << " opens to " << openedExistential.second->getString(PO);
out << "\n";
@@ -1611,7 +1616,7 @@ void ConstraintSystem::print(raw_ostream &out) const {
}
if (!DefaultedConstraints.empty()) {
out << "\nDefaulted constraints:\n";
out.indent(indent) << "Defaulted constraints:\n";
interleave(DefaultedConstraints, [&](ConstraintLocator *locator) {
locator->dump(&getASTContext().SourceMgr, out);
}, [&] {
@@ -1621,16 +1626,16 @@ void ConstraintSystem::print(raw_ostream &out) const {
}
if (failedConstraint) {
out << "\nFailed constraint:\n";
out.indent(2);
failedConstraint->print(out, &getASTContext().SourceMgr);
out.indent(indent) << "Failed constraint:\n";
failedConstraint->print(out.indent(indent + 2), &getASTContext().SourceMgr,
indent + 2);
out << "\n";
}
if (!Fixes.empty()) {
out << "\nFixes:\n";
out.indent(indent) << "Fixes:\n";
for (auto *fix : Fixes) {
out.indent(2);
out.indent(indent + 2);
fix->print(out);
out << "\n";
}