diff --git a/include/swift/AST/FileUnit.h b/include/swift/AST/FileUnit.h index 0417ea84636..51cc26bd8e4 100644 --- a/include/swift/AST/FileUnit.h +++ b/include/swift/AST/FileUnit.h @@ -16,6 +16,7 @@ #include "swift/AST/Module.h" #include "swift/AST/RawComment.h" #include "swift/Basic/BasicSourceInfo.h" +#include "swift/Basic/Debug.h" #include "llvm/ADT/PointerIntPair.h" @@ -308,6 +309,9 @@ public: return getParentModule()->getRealName().str(); } + SWIFT_DEBUG_DUMPER(dumpDisplayDecls()); + SWIFT_DEBUG_DUMPER(dumpTopLevelDecls()); + /// Traverse the decls within this file. /// /// \returns true if traversal was aborted, false if it completed diff --git a/include/swift/AST/Module.h b/include/swift/AST/Module.h index 46ed457ba8b..18b985bc372 100644 --- a/include/swift/AST/Module.h +++ b/include/swift/AST/Module.h @@ -26,6 +26,7 @@ #include "swift/AST/Type.h" #include "swift/Basic/BasicSourceInfo.h" #include "swift/Basic/Compiler.h" +#include "swift/Basic/Debug.h" #include "swift/Basic/OptionSet.h" #include "swift/Basic/STLExtras.h" #include "swift/Basic/SourceLoc.h" @@ -856,6 +857,9 @@ public: /// transferred from module files to the dSYMs, remove this. bool isExternallyConsumed() const; + SWIFT_DEBUG_DUMPER(dumpDisplayDecls()); + SWIFT_DEBUG_DUMPER(dumpTopLevelDecls()); + SourceRange getSourceRange() const { return SourceRange(); } static bool classof(const DeclContext *DC) { diff --git a/lib/AST/Module.cpp b/lib/AST/Module.cpp index fd9ed704cdc..b98f75b14b7 100644 --- a/lib/AST/Module.cpp +++ b/lib/AST/Module.cpp @@ -788,6 +788,24 @@ void ModuleDecl::getTopLevelDecls(SmallVectorImpl &Results) const { FORWARD(getTopLevelDecls, (Results)); } +void ModuleDecl::dumpDisplayDecls() const { + SmallVector Decls; + getDisplayDecls(Decls); + for (auto *D : Decls) { + D->dump(llvm::errs()); + llvm::errs() << "\n"; + } +} + +void ModuleDecl::dumpTopLevelDecls() const { + SmallVector Decls; + getTopLevelDecls(Decls); + for (auto *D : Decls) { + D->dump(llvm::errs()); + llvm::errs() << "\n"; + } +} + void ModuleDecl::getExportedPrespecializations( SmallVectorImpl &Results) const { FORWARD(getExportedPrespecializations, (Results)); @@ -3062,6 +3080,22 @@ void FileUnit::getTopLevelDeclsWhereAttributesMatch( Results.erase(newEnd, Results.end()); } +void FileUnit::dumpDisplayDecls() const { + SmallVector Decls; + getDisplayDecls(Decls); + for (auto *D : Decls) { + D->dump(llvm::errs()); + } +} + +void FileUnit::dumpTopLevelDecls() const { + SmallVector Decls; + getTopLevelDecls(Decls); + for (auto *D : Decls) { + D->dump(llvm::errs()); + } +} + void swift::simple_display(llvm::raw_ostream &out, const FileUnit *file) { if (!file) { out << "(null)";