Drop TypeCheckerDebugConsumer

This commit is contained in:
Robert Widmann
2020-05-18 22:49:55 -07:00
parent 4c5d87e07c
commit afe8f2b63f
14 changed files with 65 additions and 183 deletions

View File

@@ -379,9 +379,8 @@ ConstraintSystem::SolverState::SolverState(
if (tyOpts.DebugConstraintSolverAttempt &&
tyOpts.DebugConstraintSolverAttempt == SolutionAttempt) {
CS.Options |= ConstraintSystemFlags::DebugConstraints;
llvm::raw_ostream &dbgOut = ctx.TypeCheckerDebug->getStream();
dbgOut << "---Constraint system #" << SolutionAttempt << "---\n";
CS.print(dbgOut);
llvm::errs() << "---Constraint system #" << SolutionAttempt << "---\n";
CS.print(llvm::errs());
}
}
@@ -632,7 +631,7 @@ bool ConstraintSystem::Candidate::solve(
auto &ctx = cs.getASTContext();
if (cs.isDebugMode()) {
auto &log = ctx.TypeCheckerDebug->getStream();
auto &log = llvm::errs();
log << "--- Solving candidate for shrinking at ";
auto R = E->getSourceRange();
if (R.isValid()) {
@@ -669,7 +668,7 @@ bool ConstraintSystem::Candidate::solve(
}
if (cs.isDebugMode()) {
auto &log = ctx.TypeCheckerDebug->getStream();
auto &log = llvm::errs();
if (solutions.empty()) {
log << "--- No Solutions ---\n";
} else {
@@ -1143,15 +1142,14 @@ Optional<std::vector<Solution>> ConstraintSystem::solve(
auto dumpSolutions = [&](const SolutionResult &result) {
// Debug-print the set of solutions.
if (isDebugMode()) {
auto &log = getASTContext().TypeCheckerDebug->getStream();
if (result.getKind() == SolutionResult::Success) {
log << "---Solution---\n";
result.getSolution().dump(log);
llvm::errs() << "---Solution---\n";
result.getSolution().dump(llvm::errs());
} else if (result.getKind() == SolutionResult::Ambiguous) {
auto solutions = result.getAmbiguousSolutions();
for (unsigned i : indices(solutions)) {
log << "--- Solution #" << i << " ---\n";
solutions[i].dump(log);
llvm::errs() << "--- Solution #" << i << " ---\n";
solutions[i].dump(llvm::errs());
}
}
}
@@ -1230,7 +1228,7 @@ SolutionResult
ConstraintSystem::solveImpl(SolutionApplicationTarget &target,
FreeTypeVariableBinding allowFreeTypeVariables) {
if (isDebugMode()) {
auto &log = getASTContext().TypeCheckerDebug->getStream();
auto &log = llvm::errs();
log << "---Constraint solving at ";
auto R = target.getSourceRange();
if (R.isValid()) {
@@ -1278,7 +1276,7 @@ bool ConstraintSystem::solve(SmallVectorImpl<Solution> &solutions,
solveImpl(solutions);
if (isDebugMode()) {
auto &log = getASTContext().TypeCheckerDebug->getStream();
auto &log = llvm::errs();
log << "---Solver statistics---\n";
log << "Total number of scopes explored: " << solverState->NumStatesExplored << "\n";
log << "Maximum depth reached while exploring solutions: " << solverState->maxDepth << "\n";
@@ -1415,11 +1413,10 @@ ConstraintSystem::filterDisjunction(
}
if (isDebugMode()) {
auto &log = ctx.TypeCheckerDebug->getStream();
log.indent(solverState ? solverState->depth * 2 : 0)
llvm::errs().indent(solverState ? solverState->depth * 2 : 0)
<< "(disabled disjunction term ";
constraint->print(log, &ctx.SourceMgr);
log << ")\n";
constraint->print(llvm::errs(), &ctx.SourceMgr);
llvm::errs() << ")\n";
}
if (restoreOnFail)
@@ -1476,11 +1473,10 @@ ConstraintSystem::filterDisjunction(
}
if (isDebugMode()) {
auto &log = ctx.TypeCheckerDebug->getStream();
log.indent(solverState ? solverState->depth * 2 : 0)
llvm::errs().indent(solverState ? solverState->depth * 2 : 0)
<< "(introducing single enabled disjunction term ";
choice->print(log, &ctx.SourceMgr);
log << ")\n";
choice->print(llvm::errs(), &ctx.SourceMgr);
llvm::errs() << ")\n";
}
simplifyDisjunctionChoice(choice);
@@ -1747,7 +1743,7 @@ void ConstraintSystem::ArgumentInfoCollector::minimizeLiteralProtocols() {
}
void ConstraintSystem::ArgumentInfoCollector::dump() const {
auto &log = CS.getASTContext().TypeCheckerDebug->getStream();
auto &log = llvm::errs();
log << "types:\n";
for (auto type : Types)
type->print(log);