forked from OSchip/llvm-project
Get rid of the lame attempt to prioritize "void" functions at
statement context; it really isn't helpful in practice (remember printf!) and we'll be doing other adjustments for statements very soon. llvm-svn: 114358
This commit is contained in:
parent
9dcf58a546
commit
db5c09a8cd
|
@ -70,11 +70,6 @@ enum {
|
|||
enum {
|
||||
/// \brief The result is in a base class.
|
||||
CCD_InBaseClass = 2,
|
||||
/// \brief The result is a type match against void.
|
||||
///
|
||||
/// Since everything converts to "void", we don't give as drastic an
|
||||
/// adjustment for matching void.
|
||||
CCD_VoidMatch = -5,
|
||||
/// \brief The result is a C++ non-static member function whose qualifiers
|
||||
/// exactly match the object type on which the member function can be called.
|
||||
CCD_ObjectQualifierMatch = -1,
|
||||
|
|
|
@ -625,12 +625,9 @@ void ResultBuilder::AdjustResultPriorityForPreferredType(Result &R) {
|
|||
|
||||
CanQualType TC = SemaRef.Context.getCanonicalType(T);
|
||||
// Check for exactly-matching types (modulo qualifiers).
|
||||
if (SemaRef.Context.hasSameUnqualifiedType(PreferredType, TC)) {
|
||||
if (PreferredType->isVoidType())
|
||||
R.Priority += CCD_VoidMatch;
|
||||
else
|
||||
R.Priority /= CCF_ExactTypeMatch;
|
||||
} // Check for nearly-matching types, based on classification of each.
|
||||
if (SemaRef.Context.hasSameUnqualifiedType(PreferredType, TC))
|
||||
R.Priority /= CCF_ExactTypeMatch;
|
||||
// Check for nearly-matching types, based on classification of each.
|
||||
else if ((getSimplifiedTypeClass(PreferredType)
|
||||
== getSimplifiedTypeClass(TC)) &&
|
||||
!(PreferredType->isEnumeralType() && TC->isEnumeralType()))
|
||||
|
@ -2571,12 +2568,6 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
|
|||
break;
|
||||
|
||||
case PCC_Statement:
|
||||
// For statements that are expressions, we prefer to call 'void' functions
|
||||
// rather than functions that return a result, since then the result would
|
||||
// be ignored.
|
||||
Results.setPreferredType(Context.VoidTy);
|
||||
// Fall through
|
||||
|
||||
case PCC_ParenthesizedExpression:
|
||||
case PCC_Expression:
|
||||
case PCC_ForInit:
|
||||
|
|
|
@ -26,8 +26,8 @@ void test_B(B *b) {
|
|||
}
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
|
||||
// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)}{RightParen )} (45)
|
||||
// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)}{RightParen )} (45)
|
||||
// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)}{RightParen )} (50)
|
||||
// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)}{RightParen )} (50)
|
||||
// RUN: c-index-test -code-completion-at=%s:17:6 %s | FileCheck -check-prefix=CHECK-CC2 %s
|
||||
// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2:}{Placeholder ^(float f, double d)} (20)
|
||||
// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method:}{Placeholder ^int(int x, int y)} (20)
|
||||
|
|
|
@ -54,7 +54,7 @@ void f5(float f) {
|
|||
// CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) (deprecated)
|
||||
|
||||
// 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 )} (45)
|
||||
// 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)
|
||||
|
||||
|
|
|
@ -60,22 +60,22 @@ void Foo::bingo() volatile {
|
|||
|
||||
// Check implicit member access expressions.
|
||||
// RUN: c-index-test -code-completion-at=%s:29:2 %s | FileCheck -check-prefix=CHECK-IMPLICIT-NOQUALS %s
|
||||
// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15)
|
||||
// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (14)
|
||||
// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (15)
|
||||
// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (15)
|
||||
// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20)
|
||||
// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (19)
|
||||
// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (20)
|
||||
// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (20)
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:33:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-CONST %s
|
||||
// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15)
|
||||
// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20)
|
||||
// CHECK-IMPLICIT-CONST-NOT: bar
|
||||
// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (14)
|
||||
// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (19)
|
||||
// CHECK-IMPLICIT-CONST-NOT: bingo
|
||||
// CHECK-IMPLICIT-CONST: theend
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:37:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-VOLATILE %s
|
||||
// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15)
|
||||
// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20)
|
||||
// CHECK-IMPLICIT-VOLATILE-NOT: baz
|
||||
// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (14)
|
||||
// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (19)
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:4:17 %s | FileCheck -check-prefix=CHECK-CVQUAL-AFTER %s
|
||||
// CHECK-CVQUAL-AFTER: NotImplemented:{TypedText const} (30)
|
||||
|
|
|
@ -25,8 +25,8 @@ void B::bar(float real) {
|
|||
|
||||
// RUN: c-index-test -code-completion-at=%s:20:3 %s | FileCheck -check-prefix=CHECK-BAR-UNQUAL %s
|
||||
// CHECK-BAR-UNQUAL: CXXMethod:{Text A::}{TypedText bar}{LeftParen (}{Placeholder real}{RightParen )} (8)
|
||||
// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{Placeholder float real}{RightParen )} (14)
|
||||
// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{Text A::}{TypedText bar}{LeftParen (}{Placeholder double x}{RightParen )} (16)
|
||||
// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{Placeholder float real}{RightParen )} (19)
|
||||
// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{Text A::}{TypedText bar}{LeftParen (}{Placeholder double x}{RightParen )} (21)
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:16:6 %s | FileCheck -check-prefix=CHECK-FOO-QUAL %s
|
||||
// CHECK-FOO-QUAL: CXXMethod:{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (8)
|
||||
|
|
|
@ -15,5 +15,5 @@ void test() {
|
|||
}
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:14:2 %s | FileCheck %s
|
||||
// CHECK: FunctionTemplate:{ResultType void}{TypedText f}{LeftParen (}{Placeholder T}{RightParen )} (45)
|
||||
// CHECK: FunctionTemplate:{ResultType void}{TypedText f}{LeftParen (}{Placeholder T}{RightParen )} (50)
|
||||
// CHECK: ClassTemplate:{TypedText X}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
|
||||
|
|
|
@ -19,6 +19,6 @@ void f(int x) {
|
|||
// CHECK-DIAG: preamble.h:4:7:{4:9-4:13}: warning: incompatible pointer types assigning to 'int *' from 'float *'
|
||||
// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:6:1 -I %S/Inputs -include %t %s 2> %t.stderr.txt | FileCheck -check-prefix CHECK-CC %s
|
||||
// CHECK-CC: FunctionDecl:{ResultType int}{TypedText bar}{LeftParen (}{Placeholder int i}{RightParen )} (50)
|
||||
// CHECK-CC: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int x}{RightParen )} (45)
|
||||
// CHECK-CC: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int x}{RightParen )} (50)
|
||||
// CHECK-CC: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{Placeholder int}{RightParen )} (50)
|
||||
// CHECK-CC: FunctionDecl:{ResultType int}{TypedText wibble}{LeftParen (}{Placeholder int}{RightParen )} (50)
|
||||
|
|
Loading…
Reference in New Issue