Skip to content

Commit c80776b

Browse files
committed
Update code to print conformances if SILPrintGenericSpecializationInfo is true
1 parent b2a742c commit c80776b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

include/swift/AST/ProtocolConformanceRef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ class ProtocolConformanceRef {
134134
void dump(llvm::raw_ostream &out, unsigned indent = 0,
135135
bool details = true) const;
136136

137+
void print(llvm::raw_ostream &out) const;
138+
137139
bool operator==(ProtocolConformanceRef other) const {
138140
return Union == other.Union;
139141
}

lib/AST/ASTDumper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,6 +3330,13 @@ void ProtocolConformanceRef::dump(llvm::raw_ostream &out, unsigned indent,
33303330

33313331
dumpProtocolConformanceRefRec(*this, out, indent, visited);
33323332
}
3333+
3334+
void ProtocolConformanceRef::print(llvm::raw_ostream &out) const {
3335+
llvm::SmallPtrSet<const ProtocolConformance *, 8> visited;
3336+
dumpProtocolConformanceRefRec(*this, out, 0, visited);
3337+
3338+
}
3339+
33333340
void ProtocolConformance::dump() const {
33343341
auto &out = llvm::errs();
33353342
dump(out);

lib/SIL/IR/SILPrinter.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static void printGenericSpecializationInfo(
375375
raw_ostream &OS, StringRef Kind, StringRef Name,
376376
const GenericSpecializationInformation *SpecializationInfo,
377377
SubstitutionMap Subs = { }) {
378-
if (!SpecializationInfo)
378+
if (!SpecializationInfo && Subs.empty())
379379
return;
380380

381381
auto PrintSubstitutions = [&](SubstitutionMap Subs) {
@@ -384,6 +384,11 @@ static void printGenericSpecializationInfo(
384384
[&](Type type) { OS << type; },
385385
[&] { OS << ", "; });
386386
OS << '>';
387+
OS << " conformances <";
388+
interleave(Subs.getConformances(),
389+
[&](ProtocolConformanceRef conf) { conf.print(OS); },
390+
[&] { OS << ", ";});
391+
OS << '>';
387392
};
388393

389394
OS << "// Generic specialization information for " << Kind << " " << Name;
@@ -716,7 +721,9 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
716721
Ctx.printInstructionCallBack(&I);
717722
if (SILPrintGenericSpecializationInfo) {
718723
if (auto AI = ApplySite::isa(const_cast<SILInstruction *>(&I)))
719-
if (AI.getSpecializationInfo() && AI.getCalleeFunction())
724+
if ((AI.getSpecializationInfo() ||
725+
!AI.getSubstitutionMap().empty()) &&
726+
AI.getCalleeFunction())
720727
printGenericSpecializationInfo(
721728
PrintState.OS, "call-site", AI.getCalleeFunction()->getName(),
722729
AI.getSpecializationInfo(), AI.getSubstitutionMap());

0 commit comments

Comments
 (0)