diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-08-02 11:12:41 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-08-02 11:12:41 +0000 |
commit | 1cc9c0675c44054f066bf0610ea07b88a488b5e5 (patch) | |
tree | 6925f109445522be6569e057e2533666a6867181 /clang | |
parent | 006599011d6fa8d0013e0d743994a336249fa30d (diff) | |
download | bcm5719-llvm-1cc9c0675c44054f066bf0610ea07b88a488b5e5.tar.gz bcm5719-llvm-1cc9c0675c44054f066bf0610ea07b88a488b5e5.zip |
Add a debugging dump for Module (also emitted as part of the AST
reader statistics), to show the local-to-global mappings. The only
such mapping we have (at least, for now) is for source location
offsets.
llvm-svn: 136687
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Serialization/ASTReader.h | 6 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 42 |
2 files changed, 45 insertions, 3 deletions
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index bcf5384bc6e..e28179d3353 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -176,8 +176,7 @@ enum ModuleKind { /// Each instance of the Module class corresponds to a single AST file, which /// may be a precompiled header, precompiled preamble, or an AST file of some /// sort loaded as the main file, all of which are specific formulations of -/// the general notion of a "module". A module may depend on another module -/// (FIXME: or a set of other modules). +/// the general notion of a "module". A module may depend on another module. class Module { public: Module(ModuleKind Kind); @@ -403,6 +402,9 @@ public: /// \brief List of modules which this module depends on llvm::SetVector<Module *> Imports; + + /// \brief Dump debugging output for this module. + void dump(); }; /// \brief The manager for modules loaded by the ASTReader. diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 177d4c91af2..69fdf10a1a8 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4364,7 +4364,7 @@ dumpModuleIDMap(StringRef Name, } void ASTReader::dump() { - llvm::errs() << "*** AST File Remapping:\n"; + llvm::errs() << "*** PCH/Module Remappings:\n"; dumpModuleIDMap("Global bit offset map", GlobalBitOffsetsMap); dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap); dumpModuleIDMap("Global type map", GlobalTypeMap); @@ -4375,6 +4375,12 @@ void ASTReader::dump() { dumpModuleIDMap("Global macro definition map", GlobalMacroDefinitionMap); dumpModuleIDMap("Global preprocessed entity map", GlobalPreprocessedEntityMap); + + llvm::errs() << "\n*** PCH/Modules Loaded:"; + for (ModuleManager::ModuleConstIterator M = ModuleMgr.begin(), + MEnd = ModuleMgr.end(); + M != MEnd; ++M) + (*M)->dump(); } /// Return the amount of memory used by memory buffers, breaking down @@ -5477,6 +5483,40 @@ Module::~Module() { delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable); } +template<typename Key, typename Offset, unsigned InitialCapacity> +static void +dumpLocalRemap(StringRef Name, + const ContinuousRangeMap<Key, Offset, InitialCapacity> &Map) { + if (Map.begin() == Map.end()) + return; + + typedef ContinuousRangeMap<Key, Offset, InitialCapacity> MapType; + llvm::errs() << " " << Name << ":\n"; + for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end(); + I != IEnd; ++I) { + llvm::errs() << " " << I->first << " -> " << I->second + << "\n"; + } +} + +void Module::dump() { + llvm::errs() << "\nModule: " << FileName << "\n"; + if (!Imports.empty()) { + llvm::errs() << " Imports: "; + for (unsigned I = 0, N = Imports.size(); I != N; ++I) { + if (I) + llvm::errs() << ", "; + llvm::errs() << Imports[I]->FileName; + } + llvm::errs() << "\n"; + } + + // Remapping tables. + llvm::errs() << " Base source location offset: " << SLocEntryBaseOffset + << '\n'; + dumpLocalRemap("Source location offset map", SLocRemap); +} + Module *ModuleManager::lookup(StringRef Name) { const FileEntry *Entry = FileMgr.getFile(Name); return Modules[Entry]; |