diff options
author | Richard Smith <richard@metafoo.co.uk> | 2021-03-22 17:45:39 -0700 |
---|---|---|
committer | Richard Smith <richard@metafoo.co.uk> | 2021-03-22 19:07:46 -0700 |
commit | 3775d811ff6dc1ed844aee7d15263a447ee18d52 (patch) | |
tree | 10f28052754589544b168a234614fb607fe9e57c /clang/lib/Basic/Module.cpp | |
parent | a28fee9cb2eddaaa85457b6ff9869195cbfaed3d (diff) | |
download | llvm-3775d811ff6dc1ed844aee7d15263a447ee18d52.zip llvm-3775d811ff6dc1ed844aee7d15263a447ee18d52.tar.gz llvm-3775d811ff6dc1ed844aee7d15263a447ee18d52.tar.bz2 |
Improve module dumping for debugging.
* List inferred lists of imports in `#pragma clang __debug module_map`.
* Add `#pragma clang __debug modules {all,visible,building}` to dump
lists of known / visible module names or the building modules stack.
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r-- | clang/lib/Basic/Module.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 8730a5d..8d26149 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -429,7 +429,7 @@ void Module::buildVisibleModulesCache() const { } } -void Module::print(raw_ostream &OS, unsigned Indent) const { +void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const { OS.indent(Indent); if (IsFramework) OS << "framework "; @@ -535,7 +535,7 @@ void Module::print(raw_ostream &OS, unsigned Indent) const { // the module. Regular inferred submodules are OK, as we need to look at all // those header files anyway. if (!(*MI)->IsInferred || (*MI)->IsFramework) - (*MI)->print(OS, Indent + 2); + (*MI)->print(OS, Indent + 2, Dump); for (unsigned I = 0, N = Exports.size(); I != N; ++I) { OS.indent(Indent + 2); @@ -559,6 +559,13 @@ void Module::print(raw_ostream &OS, unsigned Indent) const { OS << "\n"; } + if (Dump) { + for (Module *M : Imports) { + OS.indent(Indent + 2); + llvm::errs() << "import " << M->getFullModuleName() << "\n"; + } + } + for (unsigned I = 0, N = DirectUses.size(); I != N; ++I) { OS.indent(Indent + 2); OS << "use "; @@ -619,7 +626,7 @@ void Module::print(raw_ostream &OS, unsigned Indent) const { } LLVM_DUMP_METHOD void Module::dump() const { - print(llvm::errs()); + print(llvm::errs(), 0, true); } void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc, |