mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
add module/file debug dumpers
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -788,6 +788,24 @@ void ModuleDecl::getTopLevelDecls(SmallVectorImpl<Decl*> &Results) const {
|
||||
FORWARD(getTopLevelDecls, (Results));
|
||||
}
|
||||
|
||||
void ModuleDecl::dumpDisplayDecls() const {
|
||||
SmallVector<Decl *, 32> Decls;
|
||||
getDisplayDecls(Decls);
|
||||
for (auto *D : Decls) {
|
||||
D->dump(llvm::errs());
|
||||
llvm::errs() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleDecl::dumpTopLevelDecls() const {
|
||||
SmallVector<Decl *, 32> Decls;
|
||||
getTopLevelDecls(Decls);
|
||||
for (auto *D : Decls) {
|
||||
D->dump(llvm::errs());
|
||||
llvm::errs() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleDecl::getExportedPrespecializations(
|
||||
SmallVectorImpl<Decl *> &Results) const {
|
||||
FORWARD(getExportedPrespecializations, (Results));
|
||||
@@ -3062,6 +3080,22 @@ void FileUnit::getTopLevelDeclsWhereAttributesMatch(
|
||||
Results.erase(newEnd, Results.end());
|
||||
}
|
||||
|
||||
void FileUnit::dumpDisplayDecls() const {
|
||||
SmallVector<Decl *, 32> Decls;
|
||||
getDisplayDecls(Decls);
|
||||
for (auto *D : Decls) {
|
||||
D->dump(llvm::errs());
|
||||
}
|
||||
}
|
||||
|
||||
void FileUnit::dumpTopLevelDecls() const {
|
||||
SmallVector<Decl *, 32> 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)";
|
||||
|
||||
Reference in New Issue
Block a user