Skip to content

Commit 6895b05

Browse files
author
Amritpan Kaur
committed
[ConstraintSystem] Refactor Score printing to use new method that also prints non-zero ScoreKind description.
1 parent d07d390 commit 6895b05

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

lib/Sema/CSRanking.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ void ConstraintSystem::increaseScore(ScoreKind kind, unsigned value) {
5555
if (isDebugMode() && value > 0) {
5656
if (solverState)
5757
llvm::errs().indent(solverState->depth * 2);
58-
llvm::errs() << "(increasing score due to " << getScoreKindName(kind) << ")\n";
58+
llvm::errs() << "(increasing score due to " << Score::getNameFor(kind)
59+
<< ")\n";
5960
}
6061

6162
unsigned index = static_cast<unsigned>(kind);

lib/Sema/CSStep.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,12 @@ bool SplitterStep::mergePartialSolutions() const {
241241
// Finalize this solution.
242242
auto solution = CS.finalize();
243243
solutionMemory += solution.getTotalMemory();
244-
if (CS.isDebugMode())
245-
getDebugLogger() << "(composed solution " << CS.CurrentScore << ")\n";
244+
if (CS.isDebugMode()) {
245+
auto &log = getDebugLogger();
246+
log << "(composed solution:";
247+
CS.CurrentScore.print(log);
248+
log << ")\n";
249+
}
246250

247251
// Save this solution.
248252
Solutions.push_back(std::move(solution));
@@ -429,8 +433,12 @@ StepResult ComponentStep::take(bool prevFailed) {
429433
}
430434

431435
auto solution = CS.finalize();
432-
if (CS.isDebugMode())
433-
getDebugLogger() << "(found solution " << getCurrentScore() << ")\n";
436+
if (CS.isDebugMode()) {
437+
auto &log = getDebugLogger();
438+
log << "(found solution:";
439+
getCurrentScore().print(log);
440+
log << ")\n";
441+
}
434442

435443
Solutions.push_back(std::move(solution));
436444
return finalize(/*isSuccess=*/true);

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,8 @@ void Solution::dump(raw_ostream &out) const {
12751275

12761276
SourceManager *sm = &getConstraintSystem().getASTContext().SourceMgr;
12771277

1278-
out << "Fixed score: " << FixedScore;
1278+
out << "Fixed score:";
1279+
FixedScore.print(out);
12791280

12801281
out << "\nType variables:\n";
12811282
std::vector<std::pair<TypeVariableType *, Type>> bindings(
@@ -1428,7 +1429,8 @@ void ConstraintSystem::print(raw_ostream &out) const {
14281429
PrintOptions PO;
14291430
PO.PrintTypesForDebugging = true;
14301431

1431-
out << "Score: " << CurrentScore;
1432+
out << "Score:";
1433+
CurrentScore.print(out);
14321434

14331435
for (const auto &contextualTypeEntry : contextualTypes) {
14341436
auto info = contextualTypeEntry.second.first;

0 commit comments

Comments
 (0)