[cfe-commits] r136687 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp
Douglas Gregor
dgregor at apple.com
Tue Aug 2 04:12:41 PDT 2011
Author: dgregor
Date: Tue Aug 2 06:12:41 2011
New Revision: 136687
URL: http://llvm.org/viewvc/llvm-project?rev=136687&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=136687&r1=136686&r2=136687&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Aug 2 06:12:41 2011
@@ -176,8 +176,7 @@
/// 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 @@
/// \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.
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=136687&r1=136686&r2=136687&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Aug 2 06:12:41 2011
@@ -4364,7 +4364,7 @@
}
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 @@
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 @@
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];
More information about the cfe-commits
mailing list