diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-11 17:31:05 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-11 17:31:05 +0000 |
commit | 7628294ee86c2f5459b6bf476434fdc8f4f7055e (patch) | |
tree | 94ac953d0f3334faf9de9e9bf462f0e8c9468d79 /lib/Sema/SemaCodeComplete.cpp | |
parent | 22ed438eafdc9533b6abacb191ec82c192604f0d (diff) |
Tweak code-completion results by suppressing class template
specializations and class template partial specializations (they're
never named directly). Also, member access expressions only refer to
value declarations (fields, functions, enumerators, etc.) and
Objective-C property declarations; filter out everything else.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 63c8bdcc6c..b1452b9152 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -364,11 +364,15 @@ void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) { (IDNS & (Decl::IDNS_OrdinaryFriend | Decl::IDNS_TagFriend))) return; - // Class template (partial) specializations are never added as results + // Class template (partial) specializations are never added as results. if (isa<ClassTemplateSpecializationDecl>(CanonDecl) || isa<ClassTemplatePartialSpecializationDecl>(CanonDecl)) return; + // Using declarations themselves are never added as results. + if (isa<UsingDecl>(CanonDecl)) + return; + if (const IdentifierInfo *Id = R.Declaration->getIdentifier()) { // __va_list_tag is a freak of nature. Find it and skip it. if (Id->isStr("__va_list_tag") || Id->isStr("__builtin_va_list")) @@ -571,18 +575,19 @@ bool ResultBuilder::IsNamespaceOrAlias(NamedDecl *ND) const { return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND); } -/// \brief Brief determines whether the given declaration is a namespace or -/// namespace alias. +/// \brief Determines whether the given declaration is a type. bool ResultBuilder::IsType(NamedDecl *ND) const { return isa<TypeDecl>(ND); } -/// \brief Since every declaration found within a class is a member that we -/// care about, always returns true. This predicate exists mostly to -/// communicate to the result builder that we are performing a lookup for -/// member access. +/// \brief Determines which members of a class should be visible via +/// "." or "->". Only value declarations, nested name specifiers, and +/// using declarations thereof should show up. bool ResultBuilder::IsMember(NamedDecl *ND) const { - return true; + if (UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(ND)) + ND = Using->getTargetDecl(); + + return isa<ValueDecl>(ND) || isa<ObjCPropertyDecl>(ND); } // Find the next outer declaration context corresponding to this scope. @@ -1479,6 +1484,8 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *BaseE, // We could have the start of a nested-name-specifier. Add those // results as well. + // FIXME: We should really walk base classes to produce + // nested-name-specifiers so that we produce more-precise results. Results.setFilter(&ResultBuilder::IsNestedNameSpecifier); CollectLookupResults(S, Context.getTranslationUnitDecl(), NextRank, CurContext, Results); |