Add some debugging output to the AST reader, so we can see the global remappings we generate
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135701 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index ae666b7..d7b574a 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -1169,6 +1169,9 @@
/// \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 83c894b..be2b79d 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -4277,6 +4277,60 @@
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