aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Serialization/ASTReader.h3
-rw-r--r--lib/Serialization/ASTReader.cpp54
2 files changed, 57 insertions, 0 deletions
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index ae666b717a..d7b574a774 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -1169,6 +1169,9 @@ public:
/// \brief Print some statistics about AST usage.
virtual void PrintStats();
+ /// \brief Dump information about the AST reader to standard error.
+ void dump();
+
/// Return the amount of memory used by memory buffers, breaking down
/// by heap-backed versus mmap'ed memory.
virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const;
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 83c894b648..be2b79d403 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -4277,6 +4277,60 @@ void ASTReader::PrintStats() {
std::fprintf(stderr, " %u method pool misses\n", NumMethodPoolMisses);
}
std::fprintf(stderr, "\n");
+ dump();
+ std::fprintf(stderr, "\n");
+}
+
+template<typename Key, typename PerFileData, unsigned InitialCapacity>
+static void
+dumpModuleIDMap(llvm::StringRef Name,
+ const ContinuousRangeMap<Key, PerFileData *,
+ InitialCapacity> &Map) {
+ if (Map.begin() == Map.end())
+ return;
+
+ typedef ContinuousRangeMap<Key, PerFileData *, 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->FileName
+ << "\n";
+ }
+}
+
+template<typename Key, typename PerFileData, typename Adjustment,
+ unsigned InitialCapacity>
+static void
+dumpModuleIDOffsetMap(llvm::StringRef Name,
+ const ContinuousRangeMap<Key,
+ std::pair<PerFileData *,
+ Adjustment>,
+ InitialCapacity> &Map) {
+ if (Map.begin() == Map.end())
+ return;
+
+ typedef ContinuousRangeMap<Key, std::pair<PerFileData *, Adjustment>,
+ 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.first->FileName
+ << ", " << I->second.second << ")\n";
+ }
+}
+
+void ASTReader::dump() {
+ llvm::errs() << "*** AST File Remapping:\n";
+ dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap);
+ dumpModuleIDOffsetMap("Global type map", GlobalTypeMap);
+ dumpModuleIDOffsetMap("Global declaration map", GlobalDeclMap);
+ dumpModuleIDOffsetMap("Global identifier map", GlobalIdentifierMap);
+ dumpModuleIDOffsetMap("Global selector map", GlobalSelectorMap);
+ dumpModuleIDOffsetMap("Global macro definition map",
+ GlobalMacroDefinitionMap);
+ dumpModuleIDOffsetMap("Global preprocessed entity map",
+ GlobalPreprocessedEntityMap);
+
}
/// Return the amount of memory used by memory buffers, breaking down