Skip to content

Commit f5be38d

Browse files
committed
[NFC] Add ImportSet::dump() + fix module dumpRef
1 parent 04775d4 commit f5be38d

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

include/swift/AST/ImportCache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class ImportSet final :
9898
return {getTrailingObjects<ImportedModule>(),
9999
NumTopLevelImports + NumTransitiveImports};
100100
}
101+
102+
SWIFT_DEBUG_DUMP;
101103
};
102104

103105
class alignas(ImportedModule) ImportCache {

lib/AST/ASTDumper.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,9 +1320,11 @@ std::string ValueDecl::printRef() const {
13201320
}
13211321

13221322
void ValueDecl::dumpRef(raw_ostream &os) const {
1323-
// Print the context.
1324-
printContext(os, getDeclContext());
1325-
os << ".";
1323+
if (!isa<ModuleDecl>(this)) {
1324+
// Print the context.
1325+
printContext(os, getDeclContext());
1326+
os << ".";
1327+
}
13261328

13271329
// Print name.
13281330
getName().printPretty(os);

lib/AST/ImportCache.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ void ImportSet::Profile(
6363
}
6464
}
6565

66+
void ImportSet::dump() const {
67+
llvm::errs() << "HasHeaderImportModule: " << HasHeaderImportModule << "\n";
68+
69+
llvm::errs() << "TopLevelImports:";
70+
for (auto import : getTopLevelImports()) {
71+
llvm::errs() << "\n- ";
72+
simple_display(llvm::errs(), import);
73+
}
74+
llvm::errs() << "\n";
75+
76+
llvm::errs() << "TransitiveImports:";
77+
for (auto import : getTransitiveImports()) {
78+
llvm::errs() << "\n- ";
79+
simple_display(llvm::errs(), import);
80+
}
81+
llvm::errs() << "\n";
82+
}
83+
6684
static void collectExports(ImportedModule next,
6785
SmallVectorImpl<ImportedModule> &stack) {
6886
SmallVector<ImportedModule, 4> exports;

0 commit comments

Comments
 (0)