[llvm-branch-commits] [cfe-branch] r118582 - in /cfe/branches/Apple/whitney: lib/Sema/SemaCodeComplete.cpp test/Index/complete-exprs.cpp
Daniel Dunbar
daniel at zuster.org
Tue Nov 9 09:33:02 PST 2010
Author: ddunbar
Date: Tue Nov 9 11:33:01 2010
New Revision: 118582
URL: http://llvm.org/viewvc/llvm-project?rev=118582&view=rev
Log:
Merge r118484:
--
Author: Douglas Gregor <dgregor at apple.com>
Date: Tue Nov 9 03:59:40 2010 +0000
Teach code completion not to include out-of-line declarations and
definitions in its results. The original declarations will be visible
wherever they are declared.
Modified:
cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp
cfe/branches/Apple/whitney/test/Index/complete-exprs.cpp
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp?rev=118582&r1=118581&r2=118582&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp Tue Nov 9 11:33:01 2010
@@ -505,6 +505,14 @@
}
}
+ // Skip out-of-line declarations and definitions.
+ // NOTE: Unless it's an Objective-C property, method, or ivar, where
+ // the contexts can be messy.
+ if (!ND->getDeclContext()->Equals(ND->getLexicalDeclContext()) &&
+ !(isa<ObjCPropertyDecl>(ND) || isa<ObjCIvarDecl>(ND) ||
+ isa<ObjCMethodDecl>(ND)))
+ return false;
+
if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
((isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND)) &&
Filter != &ResultBuilder::IsNamespace &&
@@ -5724,7 +5732,6 @@
void Sema::GatherGlobalCodeCompletions(
llvm::SmallVectorImpl<CodeCompletionResult> &Results) {
ResultBuilder Builder(*this, CodeCompletionContext::CCC_Recovery);
-
if (!CodeCompleter || CodeCompleter->includeGlobals()) {
CodeCompletionDeclConsumer Consumer(Builder,
Context.getTranslationUnitDecl());
Modified: cfe/branches/Apple/whitney/test/Index/complete-exprs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Index/complete-exprs.cpp?rev=118582&r1=118581&r2=118582&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/Index/complete-exprs.cpp (original)
+++ cfe/branches/Apple/whitney/test/Index/complete-exprs.cpp Tue Nov 9 11:33:01 2010
@@ -11,17 +11,19 @@
class vector {
public:
vector(const T &, unsigned n);
-
template<typename InputIterator>
vector(InputIterator first, InputIterator last);
+ void push_back(const T&);
};
-
+template<typename T> void vector<T>::push_back(const T&) { }
void f() {
}
// RUN: c-index-test -code-completion-at=%s:20:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:20:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{TypedText operator} (40)
+// CHECK-CC1-NOT: push_back
// CHECK-CC1: ClassDecl:{TypedText string} (50)
// CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{RightParen )} (50)
// CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{Placeholder const char *}{RightParen )} (50)
More information about the llvm-branch-commits
mailing list