Enhance clang_getCXTUResourceUsage() to report the amount of memory used by ASTContext's side tables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130383 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index c72d496..26e4af4 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -5198,7 +5198,7 @@
static inline void createCXTUResourceUsageEntry(MemUsageEntries &entries,
enum CXTUResourceUsageKind k,
- double amount) {
+ unsigned long amount) {
CXTUResourceUsageEntry entry = { k, amount };
entries.push_back(entry);
}
@@ -5223,6 +5223,9 @@
case CXTUResourceUsage_SourceManagerContentCache:
str = "SourceManager: content cache allocator";
break;
+ case CXTUResourceUsage_AST_SideTables:
+ str = "ASTContext: side tables";
+ break;
}
return str;
}
@@ -5239,7 +5242,7 @@
// How much memory is used by AST nodes and types?
createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_AST,
- (unsigned long) astContext.getTotalAllocatedMemory());
+ (unsigned long) astContext.getASTAllocatedMemory());
// How much memory is used by identifiers?
createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_Identifiers,
@@ -5249,6 +5252,10 @@
createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_Selectors,
(unsigned long) astContext.Selectors.getTotalMemory());
+ // How much memory is used by ASTContext's side tables?
+ createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_AST_SideTables,
+ (unsigned long) astContext.getSideTableAllocatedMemory());
+
// How much memory is used for caching global code completion results?
unsigned long completionBytes = 0;
if (GlobalCodeCompletionAllocator *completionAllocator =