[cfe-commits] r135701 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp
Douglas Gregor
dgregor at apple.com
Thu Jul 21 12:50:15 PDT 2011
Author: dgregor
Date: Thu Jul 21 14:50:14 2011
New Revision: 135701
URL: http://llvm.org/viewvc/llvm-project?rev=135701&view=rev
Log:
Add some debugging output to the AST reader, so we can see the global remappings we generate
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=135701&r1=135700&r2=135701&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jul 21 14:50:14 2011
@@ -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;
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=135701&r1=135700&r2=135701&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Jul 21 14:50:14 2011
@@ -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
More information about the cfe-commits
mailing list