[cfe-commits] r114286 - in /cfe/trunk: include/clang/Sema/CodeCompleteConsumer.h lib/Sema/CodeCompleteConsumer.cpp test/Index/complete-exprs.m
Douglas Gregor
dgregor at apple.com
Sat Sep 18 08:16:27 PDT 2010
Author: dgregor
Date: Sat Sep 18 10:16:27 2010
New Revision: 114286
URL: http://llvm.org/viewvc/llvm-project?rev=114286&view=rev
Log:
Give the Objective-C _cmd an "unlikely" code completion priority; it's
very rarely used.
Added:
cfe/trunk/test/Index/complete-exprs.m
Modified:
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=114286&r1=114285&r2=114286&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Sat Sep 18 10:16:27 2010
@@ -59,7 +59,10 @@
CCP_NestedNameSpecifier = 75,
/// \brief Priority for a result that isn't likely to be what the user wants,
/// but is included for completeness.
- CCP_Unlikely = 80
+ CCP_Unlikely = 80,
+
+ /// \brief Priority for the Objective-C "_cmd" implicit parameter.
+ CCP_ObjC_cmd = CCP_Unlikely
};
/// \brief Priority value deltas that are added to code-completion results
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=114286&r1=114285&r2=114286&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Sat Sep 18 10:16:27 2010
@@ -389,8 +389,15 @@
// Context-based decisions.
DeclContext *DC = ND->getDeclContext()->getRedeclContext();
- if (DC->isFunctionOrMethod() || isa<BlockDecl>(DC))
+ if (DC->isFunctionOrMethod() || isa<BlockDecl>(DC)) {
+ // _cmd is relatively rare
+ if (ImplicitParamDecl *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
+ if (ImplicitParam->getIdentifier() &&
+ ImplicitParam->getIdentifier()->isStr("_cmd"))
+ return CCP_ObjC_cmd;
+
return CCP_LocalDeclaration;
+ }
if (DC->isRecord() || isa<ObjCContainerDecl>(DC))
return CCP_MemberDeclaration;
@@ -399,6 +406,7 @@
return CCP_Constant;
if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))
return CCP_Type;
+
return CCP_Declaration;
}
Added: cfe/trunk/test/Index/complete-exprs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-exprs.m?rev=114286&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-exprs.m (added)
+++ cfe/trunk/test/Index/complete-exprs.m Sat Sep 18 10:16:27 2010
@@ -0,0 +1,15 @@
+ at interface A
+- (int)method:(id)param1;
+
+ at property int prop1;
+ at end
+
+ at implementation A
+- (int)method:(id)param1 {
+
+}
+ at end
+
+// RUN: c-index-test -code-completion-at=%s:9:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
+// CHECK-CC1: NotImplemented:{ResultType A *}{TypedText self} (8)
More information about the cfe-commits
mailing list