Skip to content

Commit 3c401a1

Browse files
committed
Fix unbalanced braces in debugging output
1 parent bf254cc commit 3c401a1

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

lib/Sema/CSSolver.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ bool ConstraintSystem::simplify() {
353353
auto *constraint = &ActiveConstraints.front();
354354
deactivateConstraint(constraint);
355355

356+
auto isSimplifiable =
357+
constraint->getKind() != ConstraintKind::Disjunction &&
358+
constraint->getKind() != ConstraintKind::Conjunction;
359+
356360
if (isDebugMode()) {
357361
auto &log = llvm::errs();
358362
log.indent(solverState->getCurrentIndent());
@@ -362,8 +366,7 @@ bool ConstraintSystem::simplify() {
362366

363367
// {Dis, Con}junction are returned unsolved in \c simplifyConstraint() and
364368
// handled separately by solver steps.
365-
if (constraint->getKind() != ConstraintKind::Disjunction &&
366-
constraint->getKind() != ConstraintKind::Conjunction) {
369+
if (isSimplifiable) {
367370
log.indent(solverState->getCurrentIndent() + 2)
368371
<< "(simplification result:\n";
369372
}
@@ -375,7 +378,9 @@ bool ConstraintSystem::simplify() {
375378
retireFailedConstraint(constraint);
376379
if (isDebugMode()) {
377380
auto &log = llvm::errs();
378-
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
381+
if (isSimplifiable) {
382+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
383+
}
379384
log.indent(solverState->getCurrentIndent() + 2) << "(outcome: error)\n";
380385
}
381386
break;
@@ -386,7 +391,9 @@ bool ConstraintSystem::simplify() {
386391
retireConstraint(constraint);
387392
if (isDebugMode()) {
388393
auto &log = llvm::errs();
389-
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
394+
if (isSimplifiable) {
395+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
396+
}
390397
log.indent(solverState->getCurrentIndent() + 2)
391398
<< "(outcome: simplified)\n";
392399
}
@@ -397,7 +404,9 @@ bool ConstraintSystem::simplify() {
397404
++solverState->NumUnsimplifiedConstraints;
398405
if (isDebugMode()) {
399406
auto &log = llvm::errs();
400-
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
407+
if (isSimplifiable) {
408+
log.indent(solverState->getCurrentIndent() + 2) << ")\n";
409+
}
401410
log.indent(solverState->getCurrentIndent() + 2)
402411
<< "(outcome: unsolved)\n";
403412
}

lib/Sema/CSStep.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,6 @@ StepResult ComponentStep::take(bool prevFailed) {
361361
auto *disjunction = CS.selectDisjunction();
362362

363363
if (CS.isDebugMode()) {
364-
if (!potentialBindings.empty()) {
365-
auto &log = getDebugLogger();
366-
log << "(Potential Binding(s): " << '\n';
367-
log << potentialBindings;
368-
}
369-
370364
SmallVector<Constraint *, 4> disjunctions;
371365
CS.collectDisjunctions(disjunctions);
372366
std::vector<std::string> overloadDisjunctions;
@@ -379,17 +373,24 @@ StepResult ComponentStep::take(bool prevFailed) {
379373
overloadDisjunctions.push_back(
380374
constraints[0]->getFirstType()->getString(PO));
381375
}
376+
377+
if (!potentialBindings.empty() || !overloadDisjunctions.empty()) {
378+
auto &log = getDebugLogger();
379+
log << "(Potential Binding(s): " << '\n';
380+
log << potentialBindings;
381+
}
382+
382383
if (!overloadDisjunctions.empty()) {
383384
auto &log = getDebugLogger();
384385
log.indent(2);
385386
log << "Disjunction(s) = [";
386387
interleave(overloadDisjunctions, log, ", ");
387388
log << "]\n";
389+
}
388390

389-
if (!potentialBindings.empty() || !overloadDisjunctions.empty()) {
390-
auto &log = getDebugLogger();
391-
log << ")\n";
392-
}
391+
if (!potentialBindings.empty() || !overloadDisjunctions.empty()) {
392+
auto &log = getDebugLogger();
393+
log << ")\n";
393394
}
394395
}
395396

@@ -671,7 +672,7 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
671672
auto &log = getDebugLogger();
672673
log << "(skipping " + reason + " ";
673674
choice.print(log, &ctx.SourceMgr);
674-
log << '\n';
675+
log << ")\n";
675676
}
676677

677678
return true;

0 commit comments

Comments
 (0)