aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-22 23:31:26 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-22 23:31:26 +0000
commit8e0a0e4e4554ab31d793413e0fb4d9532872a53a (patch)
tree762728ec2f56f4f238ab92c2874404be9f3be3a0 /lib/Sema/SemaCodeComplete.cpp
parent3e7253f155e1e40542a6815689adef5abc65b17b (diff)
Make sure we don't try to add code-completion results without an
active shadow map. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--lib/Sema/SemaCodeComplete.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index f0be3c68b8..ec01941901 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -189,6 +189,8 @@ getRequiredQualification(ASTContext &Context,
}
void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) {
+ assert(!ShadowMaps.empty() && "Must enter into a results scope");
+
if (R.Kind != Result::RK_Declaration) {
// For non-declaration results, just add the result.
Results.push_back(R);
@@ -1200,6 +1202,7 @@ void Sema::CodeCompleteUsing(Scope *S) {
return;
ResultBuilder Results(*this, &ResultBuilder::IsNestedNameSpecifier);
+ Results.EnterNewScope();
// If we aren't in class scope, we could see the "namespace" keyword.
if (!S->isClassScope())
@@ -1209,6 +1212,7 @@ void Sema::CodeCompleteUsing(Scope *S) {
// nested-name-specifier.
CollectLookupResults(S, Context.getTranslationUnitDecl(), 0,
CurContext, Results);
+ Results.ExitScope();
HandleCodeCompleteResults(CodeCompleter, Results.data(), Results.size());
}
@@ -1220,8 +1224,10 @@ void Sema::CodeCompleteUsingDirective(Scope *S) {
// After "using namespace", we expect to see a namespace name or namespace
// alias.
ResultBuilder Results(*this, &ResultBuilder::IsNamespaceOrAlias);
+ Results.EnterNewScope();
CollectLookupResults(S, Context.getTranslationUnitDecl(), 0, CurContext,
Results);
+ Results.ExitScope();
HandleCodeCompleteResults(CodeCompleter, Results.data(), Results.size());
}
@@ -1247,11 +1253,13 @@ void Sema::CodeCompleteNamespaceDecl(Scope *S) {
// Add the most recent definition (or extended definition) of each
// namespace to the list of results.
+ Results.EnterNewScope();
for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
NS = OrigToLatest.begin(), NSEnd = OrigToLatest.end();
NS != NSEnd; ++NS)
Results.MaybeAddResult(CodeCompleteConsumer::Result(NS->second, 0),
CurContext);
+ Results.ExitScope();
}
HandleCodeCompleteResults(CodeCompleter, Results.data(), Results.size());
@@ -1274,6 +1282,7 @@ void Sema::CodeCompleteOperatorName(Scope *S) {
typedef CodeCompleteConsumer::Result Result;
ResultBuilder Results(*this, &ResultBuilder::IsType);
+ Results.EnterNewScope();
// Add the names of overloadable operators.
#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
@@ -1292,6 +1301,7 @@ void Sema::CodeCompleteOperatorName(Scope *S) {
Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
CollectLookupResults(S, Context.getTranslationUnitDecl(), NextRank + 1,
CurContext, Results);
+ Results.ExitScope();
HandleCodeCompleteResults(CodeCompleter, Results.data(), Results.size());
}