summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-04-18 23:42:53 +0000
committerTed Kremenek <kremenek@apple.com>2011-04-18 23:42:53 +0000
commit11d1a42e841e972478df47aa6a2758d0fc66e3e5 (patch)
tree062654ee10214db309b68c69f890dce6102d9b97 /clang
parent45cc546271d5e2bc90bf6e8fd23fa629e20af47a (diff)
downloadbcm5719-llvm-11d1a42e841e972478df47aa6a2758d0fc66e3e5.tar.gz
bcm5719-llvm-11d1a42e841e972478df47aa6a2758d0fc66e3e5.zip
Report memory usage for global code completion results in CXTUMemoryUsage.
llvm-svn: 129733
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang-c/Index.h3
-rw-r--r--clang/tools/c-index-test/c-index-test.c15
-rw-r--r--clang/tools/libclang/CIndex.cpp12
3 files changed, 21 insertions, 9 deletions
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 11e060b27a4..728db906007 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -1020,8 +1020,9 @@ enum CXTUMemoryUsageKind {
CXTUMemoryUsage_AST = 1,
CXTUMemoryUsage_Identifiers = 2,
CXTUMemoryUsage_Selectors = 3,
+ CXTUMemoryUsage_GlobalCompletionResults = 4,
CXTUMemoryUsage_First = CXTUMemoryUsage_AST,
- CXTUMemoryUsage_Last = CXTUMemoryUsage_Selectors
+ CXTUMemoryUsage_Last = CXTUMemoryUsage_GlobalCompletionResults
};
/**
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index b7025fc3965..a1065a832f4 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -371,19 +371,18 @@ void PrintDiagnostics(CXTranslationUnit TU) {
}
void PrintMemoryUsage(CXTranslationUnit TU) {
- CXTUMemoryUsage usage = clang_getCXTUMemoryUsage(TU);
unsigned long total = 0.0;
- unsigned i, n;
-
+ unsigned i = 0;
+ CXTUMemoryUsage usage = clang_getCXTUMemoryUsage(TU);
fprintf(stderr, "Memory usage:\n");
- for (i = 0, n = usage.numEntries; i != n; ++i) {
+ for (i = 0 ; i != usage.numEntries; ++i) {
const char *name = clang_getTUMemoryUsageName(usage.entries[i].kind);
unsigned long amount = usage.entries[i].amount;
total += amount;
- fprintf(stderr, " %s : %ld bytes (%lf MBytes)\n", name, amount,
+ fprintf(stderr, " %s : %ld bytes (%f MBytes)\n", name, amount,
((double) amount)/(1024*1024));
}
- fprintf(stderr, " TOTAL = %ld bytes (%lf MBytes)\n", total,
+ fprintf(stderr, " TOTAL = %ld bytes (%f MBytes)\n", total,
((double) total)/(1024*1024));
clang_disposeCXTUMemoryUsage(usage);
}
@@ -1548,9 +1547,9 @@ static void print_usage(void) {
"<symbol filter> {<args>}*\n"
" c-index-test -test-annotate-tokens=<range> {<args>}*\n"
" c-index-test -test-inclusion-stack-source {<args>}*\n"
- " c-index-test -test-inclusion-stack-tu <AST file>\n"
- " c-index-test -test-print-linkage-source {<args>}*\n");
+ " c-index-test -test-inclusion-stack-tu <AST file>\n");
fprintf(stderr,
+ " c-index-test -test-print-linkage-source {<args>}*\n"
" c-index-test -test-print-typekind {<args>}*\n"
" c-index-test -print-usr [<CursorKind> {<args>}]*\n"
" c-index-test -print-usr-file <file>\n"
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 2ac57bf2080..0d0f08f4e11 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -5202,6 +5202,8 @@ const char *clang_getTUMemoryUsageName(CXTUMemoryUsageKind kind) {
break;
case CXTUMemoryUsage_Selectors:
str = "ASTContext: selectors";
+ case CXTUMemoryUsage_GlobalCompletionResults:
+ str = "Code completion: cached global results";
}
return str;
}
@@ -5228,6 +5230,16 @@ CXTUMemoryUsage clang_getCXTUMemoryUsage(CXTranslationUnit TU) {
createCXTUMemoryUsageEntry(*entries, CXTUMemoryUsage_Selectors,
(unsigned long) astContext.Selectors.getTotalMemory());
+ // How much memory is used for caching global code completion results?
+ unsigned long completionBytes = 0;
+ if (GlobalCodeCompletionAllocator *completionAllocator =
+ astUnit->getCachedCompletionAllocator().getPtr()) {
+ completionBytes = completionAllocator-> getTotalMemory();
+ }
+ createCXTUMemoryUsageEntry(*entries, CXTUMemoryUsage_GlobalCompletionResults,
+ completionBytes);
+
+
CXTUMemoryUsage usage = { (void*) entries.get(),
(unsigned) entries->size(),
entries->size() ? &(*entries)[0] : 0 };
OpenPOWER on IntegriCloud