summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-13 22:48:40 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-13 22:48:40 +0000
commitb14904c4a835c5e07a7c777696dda8180069760b (patch)
treee2bc2ee653a925e896243ceae35141137327face /clang/lib/Sema/Sema.cpp
parent3c9ed76ba5294b6c7c2070008818e42e94aa99c8 (diff)
downloadbcm5719-llvm-b14904c4a835c5e07a7c777696dda8180069760b.tar.gz
bcm5719-llvm-b14904c4a835c5e07a7c777696dda8180069760b.zip
Implement caching of code-completion results for macro definitions
when the CXTranslationUnit_CacheCompletionResults option is given to clang_parseTranslationUnit(). Essentially, we compute code-completion results for macro definitions after we have parsed the file, then store an ASTContext-agnostic version of those results (completion string, cursor kind, priority, and active contexts) in the ASTUnit. When performing code completion in that ASTUnit, we splice the macro definition results into the results provided by the actual code-completion (which has had macros turned off) before libclang gets those results. We use completion context information to only splice in those results that make sense for that context. With a completion involving all of the macros from Cocoa.h and a few other system libraries (totally ~8500 macro definitions) living in a precompiled header, we get about a 9% performance improvement from code completion, since we no longer have to deserialize all of the macro definitions from the precompiled header. Note that macro definitions are merely the canary; the cache is designed to also support other top-level declarations, which should be a bigger performance win. That optimization will be next. Note also that there is no mechanism for determining when to throw away the cache and recompute its contents. llvm-svn: 111051
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index f5c85ad99cd..95f08bdf017 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -269,8 +269,10 @@ void Sema::ActOnEndOfTranslationUnit() {
true)),
UnusedFileScopedDecls.end());
- if (!CompleteTranslationUnit)
+ if (!CompleteTranslationUnit) {
+ TUScope = 0;
return;
+ }
// Check for #pragma weak identifiers that were never declared
// FIXME: This will cause diagnostics to be emitted in a non-determinstic
@@ -340,6 +342,8 @@ void Sema::ActOnEndOfTranslationUnit() {
Diag((*I)->getLocation(), diag::warn_unused_variable)
<< cast<VarDecl>(*I)->getDeclName();
}
+
+ TUScope = 0;
}
OpenPOWER on IntegriCloud