Code completion has no reason to prefer values over types, especially
at the statement level or in Objective-C message receivers. Therefore,
just give types and declarations the same basic priority, and adjust
from there.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114374 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h
index 545596d..d9014f1 100644
--- a/include/clang/Sema/CodeCompleteConsumer.h
+++ b/include/clang/Sema/CodeCompleteConsumer.h
@@ -50,7 +50,7 @@
/// \brief Priority for a non-type declaration.
CCP_Declaration = 50,
/// \brief Priority for a type.
- CCP_Type = 60,
+ CCP_Type = CCP_Declaration,
/// \brief Priority for a constant value (e.g., enumerator).
CCP_Constant = 65,
/// \brief Priority for a preprocessor macro.
@@ -606,7 +606,7 @@
void Destroy();
- /// brief Determine a base priority for the given declaration.
+ /// \brief Determine a base priority for the given declaration.
static unsigned getPriorityFromDecl(NamedDecl *ND);
private:
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 6b9a2ac..4c05b15 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -640,7 +640,7 @@
if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
if (PreferredSelector == Method->getSelector())
R.Priority += CCD_SelectorMatch;
-
+
// If we have a preferred type, adjust the priority for results with exactly-
// matching or nearly-matching types.
if (!PreferredType.isNull()) {
diff --git a/test/Index/code-completion.cpp b/test/Index/code-completion.cpp
index 3dceec9..ddbf58e 100644
--- a/test/Index/code-completion.cpp
+++ b/test/Index/code-completion.cpp
@@ -58,8 +58,8 @@
// CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )}
// RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s
-// CHECK-EXPR: NotImplemented:{TypedText int} (60)
-// CHECK-EXPR: NotImplemented:{TypedText long} (60)
+// CHECK-EXPR: NotImplemented:{TypedText int} (50)
+// CHECK-EXPR: NotImplemented:{TypedText long} (50)
// CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (10)
// CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (5)
// CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (11)
diff --git a/test/Index/complete-declarators.cpp b/test/Index/complete-declarators.cpp
index 3c1ba8f..2c218c4 100644
--- a/test/Index/complete-declarators.cpp
+++ b/test/Index/complete-declarators.cpp
@@ -34,6 +34,6 @@
// CHECK-CC4: Namespace:{TypedText N}{Text ::} (75)
// CHECK-CC4: NotImplemented:{TypedText operator} (30)
// CHECK-CC4: NotImplemented:{TypedText volatile} (30)
-// CHECK-CC4: StructDecl:{TypedText Y} (60)
+// CHECK-CC4: StructDecl:{TypedText Y} (50)
// CHECK-CC4: StructDecl:{TypedText Z} (20)
diff --git a/test/Index/complete-exprs.c b/test/Index/complete-exprs.c
index 1034c0e..1619696 100644
--- a/test/Index/complete-exprs.c
+++ b/test/Index/complete-exprs.c
@@ -46,7 +46,7 @@
// RUN: c-index-test -code-completion-at=%s:7:2 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: macro definition:{TypedText __VERSION__} (70)
// CHECK-CC2: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
-// CHECK-CC2: NotImplemented:{TypedText float} (60)
+// CHECK-CC2: NotImplemented:{TypedText float} (50)
// CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (8)
// CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30)
// RUN: c-index-test -code-completion-at=%s:11:16 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
@@ -55,8 +55,8 @@
// RUN: c-index-test -code-completion-at=%s:19:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s
// CHECK-CC6: FunctionDecl:{ResultType void}{TypedText f3}{LeftParen (}{Placeholder const char *, ...}{Text , NULL}{RightParen )} (50)
-// CHECK-CC6: NotImplemented:{TypedText void} (60)
-// CHECK-CC6: NotImplemented:{TypedText volatile} (60)
+// CHECK-CC6: NotImplemented:{TypedText void} (50)
+// CHECK-CC6: NotImplemented:{TypedText volatile} (50)
// RUN: c-index-test -code-completion-at=%s:24:4 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s
// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:24:4 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s
diff --git a/test/Index/complete-exprs.m b/test/Index/complete-exprs.m
index 57b6e47..a193356 100644
--- a/test/Index/complete-exprs.m
+++ b/test/Index/complete-exprs.m
@@ -16,8 +16,8 @@
// RUN: c-index-test -code-completion-at=%s:13:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
-// CHECK-CC1: TypedefDecl:{TypedText BOOL} (60)
-// CHECK-CC1: macro definition:{TypedText bool} (61)
+// CHECK-CC1: TypedefDecl:{TypedText BOOL} (50)
+// CHECK-CC1: macro definition:{TypedText bool} (51)
// CHECK-CC1: macro definition:{TypedText NO} (65)
// CHECK-CC1: NotImplemented:{ResultType A *}{TypedText self} (8)
// CHECK-CC1: macro definition:{TypedText YES} (65)
diff --git a/test/Index/complete-hiding.c b/test/Index/complete-hiding.c
index 937a16d..02e54a9 100644
--- a/test/Index/complete-hiding.c
+++ b/test/Index/complete-hiding.c
@@ -25,8 +25,8 @@
// CHECK-CC1: VarDecl:{ResultType int}{TypedText ValueB} (50)
// RUN: c-index-test -code-completion-at=%s:16:10 %s > %t
// RUN: FileCheck -check-prefix=CHECK-CC2 -input-file=%t %s
-// CHECK-CC2: StructDecl:{TypedText StructA} (60)
-// CHECK-CC2-NOT: StructDecl:{TypedText StructB} (60)
-// CHECK-CC2: StructDecl:{TypedText StructC} (60)
+// CHECK-CC2: StructDecl:{TypedText StructA} (50)
+// CHECK-CC2-NOT: StructDecl:{TypedText StructB} (50)
+// CHECK-CC2: StructDecl:{TypedText StructC} (50)
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:16:10 %s > %t
// RUN: FileCheck -check-prefix=CHECK-CC2 -input-file=%t %s
diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m
index d0fb0e0..33541e7 100644
--- a/test/Index/complete-method-decls.m
+++ b/test/Index/complete-method-decls.m
@@ -121,39 +121,39 @@
// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (20)
// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (5)
// RUN: c-index-test -code-completion-at=%s:60:4 %s | FileCheck -check-prefix=CHECK-CCF %s
-// CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (60)
-// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (60)
+// CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (50)
+// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (50)
// CHECK-CCF: NotImplemented:{TypedText bycopy} (30)
// CHECK-CCF: NotImplemented:{TypedText byref} (30)
// CHECK-CCF: NotImplemented:{TypedText in} (30)
// CHECK-CCF: NotImplemented:{TypedText inout} (30)
// CHECK-CCF: NotImplemented:{TypedText oneway} (30)
// CHECK-CCF: NotImplemented:{TypedText out} (30)
-// CHECK-CCF: NotImplemented:{TypedText unsigned} (60)
-// CHECK-CCF: NotImplemented:{TypedText void} (60)
-// CHECK-CCF: NotImplemented:{TypedText volatile} (60)
+// CHECK-CCF: NotImplemented:{TypedText unsigned} (50)
+// CHECK-CCF: NotImplemented:{TypedText void} (50)
+// CHECK-CCF: NotImplemented:{TypedText volatile} (50)
// RUN: c-index-test -code-completion-at=%s:60:11 %s | FileCheck -check-prefix=CHECK-CCG %s
-// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (60)
-// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (60)
+// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (50)
+// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (50)
// CHECK-CCG-NOT: NotImplemented:{TypedText bycopy} (30)
// CHECK-CCG-NOT: NotImplemented:{TypedText byref} (30)
// CHECK-CCG: NotImplemented:{TypedText in} (30)
// CHECK-CCG: NotImplemented:{TypedText inout} (30)
// CHECK-CCG-NOT: NotImplemented:{TypedText oneway} (30)
// CHECK-CCG: NotImplemented:{TypedText out} (30)
-// CHECK-CCG: NotImplemented:{TypedText unsigned} (60)
-// CHECK-CCG: NotImplemented:{TypedText void} (60)
-// CHECK-CCG: NotImplemented:{TypedText volatile} (60)
+// CHECK-CCG: NotImplemented:{TypedText unsigned} (50)
+// CHECK-CCG: NotImplemented:{TypedText void} (50)
+// CHECK-CCG: NotImplemented:{TypedText volatile} (50)
// RUN: c-index-test -code-completion-at=%s:60:24 %s | FileCheck -check-prefix=CHECK-CCF %s
// RUN: c-index-test -code-completion-at=%s:60:26 %s | FileCheck -check-prefix=CHECK-CCH %s
-// CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (60)
-// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (60)
+// CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (50)
+// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (50)
// CHECK-CCH: NotImplemented:{TypedText bycopy} (30)
// CHECK-CCH: NotImplemented:{TypedText byref} (30)
// CHECK-CCH-NOT: NotImplemented:{TypedText in} (30)
// CHECK-CCH: NotImplemented:{TypedText inout} (30)
// CHECK-CCH: NotImplemented:{TypedText oneway} (30)
// CHECK-CCH: NotImplemented:{TypedText out} (30)
-// CHECK-CCH: NotImplemented:{TypedText unsigned} (60)
-// CHECK-CCH: NotImplemented:{TypedText void} (60)
-// CHECK-CCH: NotImplemented:{TypedText volatile} (60)
+// CHECK-CCH: NotImplemented:{TypedText unsigned} (50)
+// CHECK-CCH: NotImplemented:{TypedText void} (50)
+// CHECK-CCH: NotImplemented:{TypedText volatile} (50)
diff --git a/test/Index/complete-preprocessor.m b/test/Index/complete-preprocessor.m
index 73b8441..d6f8c08 100644
--- a/test/Index/complete-preprocessor.m
+++ b/test/Index/complete-preprocessor.m
@@ -61,16 +61,16 @@
// CHECK-CC4: macro definition:{TypedText BAR} (70)
// CHECK-CC4: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70)
// RUN: c-index-test -code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC5 %s
-// CHECK-CC5: NotImplemented:{TypedText const} (60)
-// CHECK-CC5: NotImplemented:{TypedText double} (60)
-// CHECK-CC5: NotImplemented:{TypedText enum} (60)
+// CHECK-CC5: NotImplemented:{TypedText const} (50)
+// CHECK-CC5: NotImplemented:{TypedText double} (50)
+// CHECK-CC5: NotImplemented:{TypedText enum} (50)
// CHECK-CC5: NotImplemented:{TypedText extern} (30)
-// CHECK-CC5: NotImplemented:{TypedText float} (60)
+// CHECK-CC5: NotImplemented:{TypedText float} (50)
// CHECK-CC5: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70)
-// CHECK-CC5: TypedefDecl:{TypedText id} (60)
+// CHECK-CC5: TypedefDecl:{TypedText id} (50)
// CHECK-CC5: NotImplemented:{TypedText inline} (30)
-// CHECK-CC5: NotImplemented:{TypedText int} (60)
-// CHECK-CC5: NotImplemented:{TypedText long} (60)
+// CHECK-CC5: NotImplemented:{TypedText int} (50)
+// CHECK-CC5: NotImplemented:{TypedText long} (50)
// Same tests as above, but with completion caching.
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s