[cfe-commits] r114704 - in /cfe/trunk: include/clang/Sema/CodeCompleteConsumer.h lib/Frontend/ASTUnit.cpp lib/Sema/CodeCompleteConsumer.cpp lib/Sema/SemaCodeComplete.cpp test/Index/complete-declarators.cpp
Douglas Gregor
dgregor at apple.com
Thu Sep 23 16:01:17 PDT 2010
Author: dgregor
Date: Thu Sep 23 18:01:17 2010
New Revision: 114704
URL: http://llvm.org/viewvc/llvm-project?rev=114704&view=rev
Log:
Synchronize globally-cached code completion results with the results
provided when the optimization is disabled. In particular, split
the completion context CCC_Other into two contexts: CCC_Other, which
means that it's an undisclosed context for which any other results are
unwelcome, and CCC_Recovery, which is used in recovery cases.
Since we're now using the completion context within the completion
results builder, make sure that it's always set to something.
Fixes <rdar://problem/8470644>.
Modified:
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-declarators.cpp
Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=114704&r1=114703&r2=114704&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Thu Sep 23 18:01:17 2010
@@ -146,7 +146,7 @@
class CodeCompletionContext {
public:
enum Kind {
- /// \brief An unspecified code-completion context.
+ /// \brief An unspecified code-completion context, where the
CCC_Other,
/// \brief Code completion occurred within a "top-level" completion context,
/// e.g., at namespace or global scope.
@@ -220,7 +220,10 @@
CCC_TypeQualifiers,
/// \brief Code completion in a parenthesized expression, which means that
/// we may also have types here in C and Objective-C (as well as in C++).
- CCC_ParenthesizedExpression
+ CCC_ParenthesizedExpression,
+ /// \brief An unknown context, in which we are recovering from a parsing
+ /// error and don't know which completions we should give.
+ CCC_Recovery
};
private:
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=114704&r1=114703&r2=114704&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Sep 23 18:01:17 2010
@@ -142,7 +142,7 @@
if (LangOpts.CPlusPlus)
IsNestedNameSpecifier = true;
- } else if (isa<ClassTemplateDecl>(ND) || isa<TemplateTemplateParmDecl>(ND))
+ } else if (isa<ClassTemplateDecl>(ND))
IsNestedNameSpecifier = true;
} else if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND)) {
// Values can appear in these contexts.
@@ -1523,7 +1523,8 @@
| (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1))
| (1 << (CodeCompletionContext::CCC_MemberAccess - 1))
| (1 << (CodeCompletionContext::CCC_ObjCProtocolName - 1))
- | (1 << (CodeCompletionContext::CCC_ParenthesizedExpression - 1));
+ | (1 << (CodeCompletionContext::CCC_ParenthesizedExpression - 1))
+ | (1 << (CodeCompletionContext::CCC_Recovery - 1));
if (AST.getASTContext().getLangOptions().CPlusPlus)
NormalContexts |= (1 << (CodeCompletionContext::CCC_EnumTag - 1))
@@ -1553,7 +1554,7 @@
llvm::StringSet<> &HiddenNames) {
bool OnlyTagNames = false;
switch (Context.getKind()) {
- case CodeCompletionContext::CCC_Other:
+ case CodeCompletionContext::CCC_Recovery:
case CodeCompletionContext::CCC_TopLevel:
case CodeCompletionContext::CCC_ObjCInterface:
case CodeCompletionContext::CCC_ObjCImplementation:
@@ -1584,6 +1585,7 @@
case CodeCompletionContext::CCC_NaturalLanguage:
case CodeCompletionContext::CCC_SelectorName:
case CodeCompletionContext::CCC_TypeQualifiers:
+ case CodeCompletionContext::CCC_Other:
// We're looking for nothing, or we're looking for names that cannot
// be hidden.
return;
@@ -1628,7 +1630,7 @@
// Merge the results we were given with the results we cached.
bool AddedResult = false;
unsigned InContexts
- = (Context.getKind() == CodeCompletionContext::CCC_Other? NormalContexts
+ = (Context.getKind() == CodeCompletionContext::CCC_Recovery? NormalContexts
: (1 << (Context.getKind() - 1)));
// Contains the set of names that are hidden by "local" completion results.
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=114704&r1=114703&r2=114704&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Thu Sep 23 18:01:17 2010
@@ -33,7 +33,7 @@
bool CodeCompletionContext::wantConstructorResults() const {
switch (Kind) {
- case CCC_Other:
+ case CCC_Recovery:
case CCC_Statement:
case CCC_Expression:
case CCC_ObjCMessageReceiver:
@@ -61,6 +61,7 @@
case CCC_NaturalLanguage:
case CCC_SelectorName:
case CCC_TypeQualifiers:
+ case CCC_Other:
return false;
}
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=114704&r1=114703&r2=114704&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Sep 23 18:01:17 2010
@@ -155,10 +155,12 @@
void MaybeAddConstructorResults(Result R);
public:
- explicit ResultBuilder(Sema &SemaRef, LookupFilter Filter = 0)
+ explicit ResultBuilder(Sema &SemaRef,
+ const CodeCompletionContext &CompletionContext,
+ LookupFilter Filter = 0)
: SemaRef(SemaRef), Filter(Filter), AllowNestedNameSpecifiers(false),
HasObjectTypeQualifiers(false),
- CompletionContext(CodeCompletionContext::CCC_Other) { }
+ CompletionContext(CompletionContext) { }
/// \brief Whether we should include code patterns in the completion
/// results.
@@ -208,11 +210,6 @@
return CompletionContext;
}
- /// \brief Set the code-completion context.
- void setCompletionContext(const CodeCompletionContext &CompletionContext) {
- this->CompletionContext = CompletionContext;
- }
-
/// \brief Specify whether nested-name-specifiers are allowed.
void allowNestedNameSpecifiers(bool Allow = true) {
AllowNestedNameSpecifiers = Allow;
@@ -296,6 +293,7 @@
bool IsObjCIvar(NamedDecl *ND) const;
bool IsObjCMessageReceiver(NamedDecl *ND) const;
bool IsObjCCollection(NamedDecl *ND) const;
+ bool IsImpossibleToSatisfy(NamedDecl *ND) const;
//@}
};
}
@@ -486,7 +484,8 @@
if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
((isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND)) &&
Filter != &ResultBuilder::IsNamespace &&
- Filter != &ResultBuilder::IsNamespaceOrAlias))
+ Filter != &ResultBuilder::IsNamespaceOrAlias &&
+ Filter != 0))
AsNestedNameSpecifier = true;
// Filter out any unwanted results.
@@ -1094,6 +1093,10 @@
(SemaRef.getLangOptions().CPlusPlus && T->isRecordType());
}
+bool ResultBuilder::IsImpossibleToSatisfy(NamedDecl *ND) const {
+ return false;
+}
+
/// \rief Determines whether the given declaration is an Objective-C
/// instance variable.
bool ResultBuilder::IsObjCIvar(NamedDecl *ND) const {
@@ -2567,8 +2570,15 @@
case Sema::PCC_Template:
case Sema::PCC_MemberTemplate:
+ if (S.CurContext->isFileContext())
+ return CodeCompletionContext::CCC_TopLevel;
+ else if (S.CurContext->isRecord())
+ return CodeCompletionContext::CCC_ClassStructUnion;
+ else
+ return CodeCompletionContext::CCC_Other;
+
case Sema::PCC_RecoveryInFunction:
- return CodeCompletionContext::CCC_Other;
+ return CodeCompletionContext::CCC_Recovery;
case Sema::PCC_Expression:
case Sema::PCC_ForInit:
@@ -2664,9 +2674,8 @@
void Sema::CodeCompleteOrdinaryName(Scope *S,
ParserCompletionContext CompletionContext) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
- Results.setCompletionContext(mapCodeCompletionContext(*this,
- CompletionContext));
+ ResultBuilder Results(*this,
+ mapCodeCompletionContext(*this, CompletionContext));
Results.EnterNewScope();
// Determine how to filter results, e.g., so that the names of
@@ -2758,7 +2767,10 @@
bool AllowNonIdentifiers,
bool AllowNestedNameSpecifiers) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this,
+ AllowNestedNameSpecifiers
+ ? CodeCompletionContext::CCC_PotentiallyQualifiedName
+ : CodeCompletionContext::CCC_Name);
Results.EnterNewScope();
// Type qualifiers can come after names.
@@ -2775,9 +2787,11 @@
// Add nested-name-specifiers.
if (AllowNestedNameSpecifiers) {
Results.allowNestedNameSpecifiers();
+ Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
CodeCompletionDeclConsumer Consumer(Results, CurContext);
LookupVisibleDecls(S, LookupNestedNameSpecifierName, Consumer,
CodeCompleter->includeGlobals());
+ Results.setFilter(0);
}
}
Results.ExitScope();
@@ -2806,10 +2820,8 @@
// Note that we intentionally suppress macro results here, since we do not
// encourage using macros to produce the names of entities.
- HandleCodeCompleteResults(this, CodeCompleter,
- AllowNestedNameSpecifiers
- ? CodeCompletionContext::CCC_PotentiallyQualifiedName
- : CodeCompletionContext::CCC_Name,
+ HandleCodeCompleteResults(this, CodeCompleter,
+ Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -2832,8 +2844,7 @@
void Sema::CodeCompleteExpression(Scope *S,
const CodeCompleteExpressionData &Data) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
-
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Expression);
if (Data.ObjCCollection)
Results.setFilter(&ResultBuilder::IsObjCCollection);
else if (Data.IntegralConstantExpression)
@@ -2951,7 +2962,10 @@
return;
}
- ResultBuilder Results(*this, &ResultBuilder::IsMember);
+ ResultBuilder Results(*this,
+ CodeCompletionContext(CodeCompletionContext::CCC_MemberAccess,
+ BaseType),
+ &ResultBuilder::IsMember);
Results.EnterNewScope();
if (const RecordType *Record = BaseType->getAs<RecordType>()) {
// Indicate that we are performing a member access, and the cv-qualifiers
@@ -3021,8 +3035,7 @@
// Hand off the results found for code completion.
HandleCodeCompleteResults(this, CodeCompleter,
- CodeCompletionContext(CodeCompletionContext::CCC_MemberAccess,
- BaseType),
+ Results.getCompletionContext(),
Results.data(),Results.size());
}
@@ -3056,7 +3069,7 @@
return;
}
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, ContextKind);
CodeCompletionDeclConsumer Consumer(Results, CurContext);
// First pass: look for tags.
@@ -3070,12 +3083,12 @@
LookupVisibleDecls(S, LookupNestedNameSpecifierName, Consumer);
}
- HandleCodeCompleteResults(this, CodeCompleter, ContextKind,
+ HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
Results.data(),Results.size());
}
void Sema::CodeCompleteTypeQualifiers(DeclSpec &DS) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_TypeQualifiers);
Results.EnterNewScope();
if (!(DS.getTypeQualifiers() & DeclSpec::TQ_const))
Results.AddResult("const");
@@ -3086,7 +3099,7 @@
Results.AddResult("restrict");
Results.ExitScope();
HandleCodeCompleteResults(this, CodeCompleter,
- CodeCompletionContext::CCC_TypeQualifiers,
+ Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -3156,7 +3169,7 @@
}
// Add any enumerators that have not yet been mentioned.
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Expression);
Results.EnterNewScope();
for (EnumDecl::enumerator_iterator E = Enum->enumerator_begin(),
EEnd = Enum->enumerator_end();
@@ -3359,9 +3372,9 @@
if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
return;
- ResultBuilder Results(*this);
-
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Name);
Results.EnterNewScope();
+
// The "template" keyword can follow "::" in the grammar, but only
// put it into the grammar if the nested-name-specifier is dependent.
NestedNameSpecifier *NNS = (NestedNameSpecifier *)SS.getScopeRep();
@@ -3389,7 +3402,9 @@
if (!CodeCompleter)
return;
- ResultBuilder Results(*this, &ResultBuilder::IsNestedNameSpecifier);
+ ResultBuilder Results(*this,
+ CodeCompletionContext::CCC_PotentiallyQualifiedName,
+ &ResultBuilder::IsNestedNameSpecifier);
Results.EnterNewScope();
// If we aren't in class scope, we could see the "namespace" keyword.
@@ -3404,7 +3419,7 @@
Results.ExitScope();
HandleCodeCompleteResults(this, CodeCompleter,
- CodeCompletionContext::CCC_Other,
+ CodeCompletionContext::CCC_PotentiallyQualifiedName,
Results.data(),Results.size());
}
@@ -3414,7 +3429,8 @@
// After "using namespace", we expect to see a namespace name or namespace
// alias.
- ResultBuilder Results(*this, &ResultBuilder::IsNamespaceOrAlias);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Namespace,
+ &ResultBuilder::IsNamespaceOrAlias);
Results.EnterNewScope();
CodeCompletionDeclConsumer Consumer(Results, CurContext);
LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
@@ -3429,12 +3445,20 @@
if (!CodeCompleter)
return;
- ResultBuilder Results(*this, &ResultBuilder::IsNamespace);
DeclContext *Ctx = (DeclContext *)S->getEntity();
if (!S->getParent())
Ctx = Context.getTranslationUnitDecl();
- if (Ctx && Ctx->isFileContext()) {
+ bool SuppressedGlobalResults
+ = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
+
+ ResultBuilder Results(*this,
+ SuppressedGlobalResults
+ ? CodeCompletionContext::CCC_Namespace
+ : CodeCompletionContext::CCC_Other,
+ &ResultBuilder::IsNamespace);
+
+ if (Ctx && Ctx->isFileContext() && !SuppressedGlobalResults) {
// We only want to see those namespaces that have already been defined
// within this scope, because its likely that the user is creating an
// extended namespace declaration. Keep track of the most recent
@@ -3457,7 +3481,7 @@
}
HandleCodeCompleteResults(this, CodeCompleter,
- CodeCompletionContext::CCC_Other,
+ Results.getCompletionContext(),
Results.data(),Results.size());
}
@@ -3466,12 +3490,13 @@
return;
// After "namespace", we expect to see a namespace or alias.
- ResultBuilder Results(*this, &ResultBuilder::IsNamespaceOrAlias);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Namespace,
+ &ResultBuilder::IsNamespaceOrAlias);
CodeCompletionDeclConsumer Consumer(Results, CurContext);
LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals());
HandleCodeCompleteResults(this, CodeCompleter,
- CodeCompletionContext::CCC_Namespace,
+ Results.getCompletionContext(),
Results.data(),Results.size());
}
@@ -3480,7 +3505,8 @@
return;
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this, &ResultBuilder::IsType);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Type,
+ &ResultBuilder::IsType);
Results.EnterNewScope();
// Add the names of overloadable operators.
@@ -3512,7 +3538,8 @@
if (!Constructor)
return;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this,
+ CodeCompletionContext::CCC_PotentiallyQualifiedName);
Results.EnterNewScope();
// Fill in any already-initialized fields or base classes.
@@ -3606,8 +3633,7 @@
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter,
- CodeCompletionContext::CCC_Name,
+ HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -3708,7 +3734,7 @@
void Sema::CodeCompleteObjCAtDirective(Scope *S, Decl *ObjCImpDecl,
bool InInterface) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
if (ObjCImpDecl)
AddObjCImplementationResults(getLangOptions(), Results, false);
@@ -3811,7 +3837,7 @@
}
void Sema::CodeCompleteObjCAtVisibility(Scope *S) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
AddObjCVisibilityResults(getLangOptions(), Results, false);
Results.ExitScope();
@@ -3821,7 +3847,7 @@
}
void Sema::CodeCompleteObjCAtStatement(Scope *S) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
AddObjCStatementResults(Results, false);
AddObjCExpressionResults(Results, false);
@@ -3832,7 +3858,7 @@
}
void Sema::CodeCompleteObjCAtExpression(Scope *S) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
AddObjCExpressionResults(Results, false);
Results.ExitScope();
@@ -3878,7 +3904,7 @@
unsigned Attributes = ODS.getPropertyAttributes();
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_readonly))
Results.AddResult(CodeCompletionResult("readonly"));
@@ -4079,7 +4105,7 @@
}
// Find all of the potential getters.
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
// FIXME: We need to do this because Objective-C methods don't get
@@ -4122,7 +4148,7 @@
}
// Find all of the potential getters.
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
// FIXME: We need to do this because Objective-C methods don't get
@@ -4150,7 +4176,7 @@
void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Type);
Results.EnterNewScope();
// Add context-sensitive, Objective-C parameter-passing keywords.
@@ -4369,12 +4395,9 @@
void Sema::CodeCompleteObjCMessageReceiver(Scope *S) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_ObjCMessageReceiver,
+ &ResultBuilder::IsObjCMessageReceiver);
- // Find anything that looks like it could be a message receiver.
- Results.setFilter(&ResultBuilder::IsObjCMessageReceiver);
- Results.setCompletionContext(CodeCompletionContext::CCC_ObjCMessageReceiver);
-
CodeCompletionDeclConsumer Consumer(Results, CurContext);
Results.EnterNewScope();
LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
@@ -4585,7 +4608,7 @@
unsigned NumSelIdents,
bool AtArgumentExpression,
bool IsSuper) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
AddClassMessageCompletions(*this, S, Receiver, SelIdents, NumSelIdents,
AtArgumentExpression, IsSuper, Results);
@@ -4625,7 +4648,7 @@
QualType ReceiverType = RecExpr? RecExpr->getType() : Context.getObjCIdType();
// Build the set of methods we can see.
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
// If this is a send-to-super, try to add the special "super" send
@@ -4780,7 +4803,7 @@
}
}
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_SelectorName);
Results.EnterNewScope();
for (GlobalMethodPool::iterator M = MethodPool.begin(),
MEnd = MethodPool.end();
@@ -4849,7 +4872,7 @@
void Sema::CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
unsigned NumProtocols) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_ObjCProtocolName);
Results.EnterNewScope();
// Tell the result set to ignore all of the protocols we have
@@ -4870,7 +4893,7 @@
}
void Sema::CodeCompleteObjCProtocolDecl(Scope *) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_ObjCProtocolName);
Results.EnterNewScope();
// Add all protocols.
@@ -4913,7 +4936,7 @@
}
void Sema::CodeCompleteObjCInterfaceDecl(Scope *S) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
// Add all classes.
@@ -4921,6 +4944,8 @@
false, Results);
Results.ExitScope();
+ // FIXME: Add a special context for this, use cached global completion
+ // results.
HandleCodeCompleteResults(this, CodeCompleter,
CodeCompletionContext::CCC_Other,
Results.data(),Results.size());
@@ -4928,7 +4953,7 @@
void Sema::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
SourceLocation ClassNameLoc) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
// Make sure that we ignore the class we're currently defining.
@@ -4942,13 +4967,15 @@
false, Results);
Results.ExitScope();
+ // FIXME: Add a special context for this, use cached global completion
+ // results.
HandleCodeCompleteResults(this, CodeCompleter,
CodeCompletionContext::CCC_Other,
Results.data(),Results.size());
}
void Sema::CodeCompleteObjCImplementationDecl(Scope *S) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
// Add all unimplemented classes.
@@ -4956,6 +4983,8 @@
true, Results);
Results.ExitScope();
+ // FIXME: Add a special context for this, use cached global completion
+ // results.
HandleCodeCompleteResults(this, CodeCompleter,
CodeCompletionContext::CCC_Other,
Results.data(),Results.size());
@@ -4966,7 +4995,7 @@
SourceLocation ClassNameLoc) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
// Ignore any categories we find that have already been implemented by this
// interface.
@@ -5008,7 +5037,7 @@
if (!Class)
return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
// Add all of the categories that have have corresponding interface
// declarations in this class and any of its superclasses, except for
@@ -5035,7 +5064,7 @@
void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, Decl *ObjCImpDecl) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
// Figure out where this @synthesize lives.
ObjCContainerDecl *Container
@@ -5072,7 +5101,7 @@
IdentifierInfo *PropertyName,
Decl *ObjCImpDecl) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
// Figure out where this @synthesize lives.
ObjCContainerDecl *Container
@@ -5253,7 +5282,7 @@
// Add declarations or definitions for each of the known methods.
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
PrintingPolicy Policy(Context.PrintingPolicy);
Policy.AnonymousTagLocations = false;
@@ -5366,7 +5395,7 @@
// Build the set of methods we can see.
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, CodeCompletionContext::CCC_Other);
if (ReturnTy)
Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
@@ -5412,7 +5441,8 @@
}
void Sema::CodeCompletePreprocessorDirective(bool InConditional) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this,
+ CodeCompletionContext::CCC_PreprocessorDirective);
Results.EnterNewScope();
// #if <condition>
@@ -5593,7 +5623,9 @@
}
void Sema::CodeCompletePreprocessorMacroName(bool IsDefinition) {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this,
+ IsDefinition? CodeCompletionContext::CCC_MacroName
+ : CodeCompletionContext::CCC_MacroNameUse);
if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
// Add just the names of macros, not their arguments.
Results.EnterNewScope();
@@ -5609,14 +5641,13 @@
// FIXME: Can we detect when the user just wrote an include guard above?
}
- HandleCodeCompleteResults(this, CodeCompleter,
- IsDefinition? CodeCompletionContext::CCC_MacroName
- : CodeCompletionContext::CCC_MacroNameUse,
+ HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
void Sema::CodeCompletePreprocessorExpression() {
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this,
+ CodeCompletionContext::CCC_PreprocessorExpression);
if (!CodeCompleter || CodeCompleter->includeMacros())
AddMacroResults(PP, Results);
@@ -5657,7 +5688,7 @@
void Sema::GatherGlobalCodeCompletions(
llvm::SmallVectorImpl<CodeCompletionResult> &Results) {
- ResultBuilder Builder(*this);
+ ResultBuilder Builder(*this, CodeCompletionContext::CCC_Recovery);
if (!CodeCompleter || CodeCompleter->includeGlobals()) {
CodeCompletionDeclConsumer Consumer(Builder,
Modified: cfe/trunk/test/Index/complete-declarators.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-declarators.cpp?rev=114704&r1=114703&r2=114704&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-declarators.cpp (original)
+++ cfe/trunk/test/Index/complete-declarators.cpp Thu Sep 23 18:01:17 2010
@@ -15,25 +15,29 @@
};
// RUN: c-index-test -code-completion-at=%s:8:5 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:8:5 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: NotImplemented:{TypedText const} (30)
// CHECK-CC1: Namespace:{TypedText N}{Text ::} (75)
// CHECK-CC1: NotImplemented:{TypedText operator} (30)
// CHECK-CC1: NotImplemented:{TypedText volatile} (30)
// RUN: c-index-test -code-completion-at=%s:8:11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:8:11 %s | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: NotImplemented:{TypedText const} (30)
// CHECK-CC2-NOT: Namespace:{TypedText N}{Text ::} (75)
// CHECK-CC2-NOT: NotImplemented:{TypedText operator} (30)
// CHECK-CC2: NotImplemented:{TypedText volatile} (30)
// RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:13:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
// CHECK-CC3: NotImplemented:{TypedText const} (30)
// CHECK-CC3-NOT: Namespace:{TypedText N}{Text ::} (75)
// CHECK-CC3: NotImplemented:{TypedText operator} (30)
// CHECK-CC3: NotImplemented:{TypedText volatile} (30)
// RUN: c-index-test -code-completion-at=%s:14:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
// CHECK-CC4: NotImplemented:{TypedText const} (30)
// CHECK-CC4: Namespace:{TypedText N}{Text ::} (75)
// CHECK-CC4: NotImplemented:{TypedText operator} (30)
// CHECK-CC4: NotImplemented:{TypedText volatile} (30)
-// CHECK-CC4: StructDecl:{TypedText Y} (50)
-// CHECK-CC4: StructDecl:{TypedText Z} (20)
+// CHECK-CC4: StructDecl:{TypedText Y}{Text ::} (75)
+// CHECK-CC4: StructDecl:{TypedText Z}{Text ::} (75)
More information about the cfe-commits
mailing list