From: Douglas Gregor Date: Tue, 24 Aug 2010 23:40:45 +0000 (+0000) Subject: In code-completion contexts where both types and other values are X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d43dd83a973c585c39a9a5e5e904282bc2371986;p=clang In code-completion contexts where both types and other values are present, prefer values to types, since it's more common to compute with values than it is to declare new entities or perform type casts. So, tweak the ranking of types vs. other declarations and constants accordingly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111998 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h index 8b5a741ebd..87974f1452 100644 --- a/include/clang/Sema/CodeCompleteConsumer.h +++ b/include/clang/Sema/CodeCompleteConsumer.h @@ -40,12 +40,12 @@ enum { CCP_Keyword = 30, /// \brief Priority for a code pattern. CCP_CodePattern = 30, - /// \brief Priority for a type. - CCP_Type = 40, /// \brief Priority for a non-type declaration. CCP_Declaration = 50, /// \brief Priority for a constant value (e.g., enumerator). CCP_Constant = 60, + /// \brief Priority for a type. + CCP_Type = 65, /// \brief Priority for a preprocessor macro. CCP_Macro = 70, /// \brief Priority for a nested-name-specifier. diff --git a/test/Index/code-completion.cpp b/test/Index/code-completion.cpp index cd0317f153..354e746166 100644 --- a/test/Index/code-completion.cpp +++ b/test/Index/code-completion.cpp @@ -58,8 +58,8 @@ Z::operator int() const { // 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} (40) -// CHECK-EXPR: NotImplemented:{TypedText long} (40) +// CHECK-EXPR: NotImplemented:{TypedText int} (65) +// CHECK-EXPR: NotImplemented:{TypedText long} (65) // 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 ba16e22ec1..61d7765892 100644 --- a/test/Index/complete-declarators.cpp +++ b/test/Index/complete-declarators.cpp @@ -34,6 +34,6 @@ struct Z { // CHECK-CC4: NotImplemented:{TypedText N}{Text ::} (75) // CHECK-CC4: NotImplemented:{TypedText operator} (30) // CHECK-CC4: NotImplemented:{TypedText volatile} (30) -// CHECK-CC4: StructDecl:{TypedText Y} (40) +// CHECK-CC4: StructDecl:{TypedText Y} (65) // CHECK-CC4: StructDecl:{TypedText Z} (20) diff --git a/test/Index/complete-exprs.c b/test/Index/complete-exprs.c index a94b7f6f77..f64706c866 100644 --- a/test/Index/complete-exprs.c +++ b/test/Index/complete-exprs.c @@ -23,7 +23,7 @@ void f4(const char* str) { // CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (60) // CHECK-CC1: macro definition:{TypedText __VERSION__} (70) // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable) -// CHECK-CC1-NOT: NotImplemented:{TypedText float} (40) +// CHECK-CC1-NOT: NotImplemented:{TypedText float} (65) // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (2) // CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1a %s @@ -36,7 +36,7 @@ void f4(const char* str) { // RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s // CHECK-CC3: macro definition:{TypedText __VERSION__} (70) // CHECK-CC3: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50) -// CHECK-CC3-NOT: NotImplemented:{TypedText float} (40) +// CHECK-CC3-NOT: NotImplemented:{TypedText float} (65) // CHECK-CC3: ParmDecl:{ResultType int}{TypedText j} (8) // CHECK-CC3: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expressio @@ -45,7 +45,7 @@ void f4(const char* str) { // 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} (40) +// CHECK-CC2: NotImplemented:{TypedText float} (65) // 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 @@ -53,10 +53,10 @@ void f4(const char* str) { // CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) (deprecated) // RUN: c-index-test -code-completion-at=%s:13:28 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC5 %s -// CHECK-CC5: NotImplemented:{TypedText void} (40) -// CHECK-CC5: NotImplemented:{TypedText volatile} (40) +// CHECK-CC5: NotImplemented:{TypedText void} (65) +// CHECK-CC5: NotImplemented:{TypedText volatile} (65) // 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 char const *}{Placeholder , ...}{Text , NULL}{RightParen )} (50) -// CHECK-CC6: NotImplemented:{TypedText void} (40) -// CHECK-CC6: NotImplemented:{TypedText volatile} (40) +// CHECK-CC6: NotImplemented:{TypedText void} (65) +// CHECK-CC6: NotImplemented:{TypedText volatile} (65) diff --git a/test/Index/complete-hiding.c b/test/Index/complete-hiding.c index 0505abfa47..f2e177571c 100644 --- a/test/Index/complete-hiding.c +++ b/test/Index/complete-hiding.c @@ -23,7 +23,7 @@ void f() { // CHECK-CC1-NOT: VarDecl:{ResultType int}{TypedText ValueA} (50) // CHECK-CC1: VarDecl:{ResultType int}{TypedText ValueB} (50) // RUN: c-index-test -code-completion-at=%s:16:10 %s | FileCheck -check-prefix=CHECK-CC2 %s -// CHECK-CC2: StructDecl:{TypedText StructA} (40) -// CHECK-CC2-NOT: StructDecl:{TypedText StructB} (40) -// CHECK-CC2: StructDecl:{TypedText StructC} (40) +// CHECK-CC2: StructDecl:{TypedText StructA} (65) +// CHECK-CC2-NOT: StructDecl:{TypedText StructB} (65) +// CHECK-CC2: StructDecl:{TypedText StructC} (65) // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:16:10 %s | FileCheck -check-prefix=CHECK-CC2 %s diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m index 20f6c60078..5a5ee6963a 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} (40) -// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (40) +// CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (65) // 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} (40) -// CHECK-CCF: NotImplemented:{TypedText void} (40) -// CHECK-CCF: NotImplemented:{TypedText volatile} (40) +// CHECK-CCF: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCF: NotImplemented:{TypedText void} (65) +// CHECK-CCF: NotImplemented:{TypedText volatile} (65) // RUN: c-index-test -code-completion-at=%s:60:11 %s | FileCheck -check-prefix=CHECK-CCG %s -// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (40) -// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (40) +// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (65) // 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} (40) -// CHECK-CCG: NotImplemented:{TypedText void} (40) -// CHECK-CCG: NotImplemented:{TypedText volatile} (40) +// CHECK-CCG: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCG: NotImplemented:{TypedText void} (65) +// CHECK-CCG: NotImplemented:{TypedText volatile} (65) // 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} (40) -// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (40) +// CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (65) // 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} (40) -// CHECK-CCH: NotImplemented:{TypedText void} (40) -// CHECK-CCH: NotImplemented:{TypedText volatile} (40) +// CHECK-CCH: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCH: NotImplemented:{TypedText void} (65) +// CHECK-CCH: NotImplemented:{TypedText volatile} (65) diff --git a/test/Index/complete-preprocessor.m b/test/Index/complete-preprocessor.m index 5a20c1c333..6ca7214fa2 100644 --- a/test/Index/complete-preprocessor.m +++ b/test/Index/complete-preprocessor.m @@ -61,13 +61,13 @@ FOO(in,t) value; // 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} (40) -// CHECK-CC5: NotImplemented:{TypedText double} (40) -// CHECK-CC5: NotImplemented:{TypedText enum} (40) +// CHECK-CC5: NotImplemented:{TypedText const} (65) +// CHECK-CC5: NotImplemented:{TypedText double} (65) +// CHECK-CC5: NotImplemented:{TypedText enum} (65) // CHECK-CC5: NotImplemented:{TypedText extern} (30) -// CHECK-CC5: NotImplemented:{TypedText float} (40) +// CHECK-CC5: NotImplemented:{TypedText float} (65) // CHECK-CC5: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70) -// CHECK-CC5: TypedefDecl:{TypedText id} (40) +// CHECK-CC5: TypedefDecl:{TypedText id} (65) // CHECK-CC5: NotImplemented:{TypedText inline} (30) -// CHECK-CC5: NotImplemented:{TypedText int} (40) -// CHECK-CC5: NotImplemented:{TypedText long} (40) +// CHECK-CC5: NotImplemented:{TypedText int} (65) +// CHECK-CC5: NotImplemented:{TypedText long} (65)