Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp @@ -10,7 +10,7 @@ // This file defines the code-completion semantic actions. // //===----------------------------------------------------------------------===// -#include "clang/Sema/SemaInternal.h" +#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" @@ -23,6 +23,7 @@ #include "clang/Sema/Overload.h" #include "clang/Sema/Scope.h" #include "clang/Sema/ScopeInfo.h" +#include "clang/Sema/SemaInternal.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallPtrSet.h" @@ -741,8 +742,18 @@ } const DeclContext *DC = ND->getDeclContext()->getRedeclContext(); - if (DC->isRecord() || isa(DC)) + if (DC->isRecord() || isa(DC)) { + // Explicit destructor calls are very rare. + if (isa(ND)) + return CCP_Unlikely; + // Explicit operator and conversion function calls are also very rare. + auto DeclNameKind = ND->getDeclName().getNameKind(); + if (DeclNameKind == DeclarationName::CXXOperatorName || + DeclNameKind == DeclarationName::CXXLiteralOperatorName || + DeclNameKind == DeclarationName::CXXConversionFunctionName) + return CCP_Unlikely; return CCP_MemberDeclaration; + } // Content-based decisions. if (isa(ND)) Index: cfe/trunk/test/Index/complete-access-checks.cpp =================================================================== --- cfe/trunk/test/Index/complete-access-checks.cpp +++ cfe/trunk/test/Index/complete-access-checks.cpp @@ -41,12 +41,12 @@ // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member1} (37) // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37) (inaccessible) // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member3} (37) (inaccessible) -// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (34) -// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (36) +// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (79) +// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (81) // CHECK-SUPER-ACCESS: StructDecl:{TypedText X}{Text ::} (77) // CHECK-SUPER-ACCESS: StructDecl:{TypedText Y}{Text ::} (75) -// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (36) -// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (34) +// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (81) +// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (79) // CHECK-ACCESS: CXXMethod:{ResultType void}{TypedText func1}{LeftParen (}{RightParen )} (34) // CHECK-ACCESS: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) (inaccessible) @@ -54,9 +54,9 @@ // CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member1} (35) // CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member2} (35) (inaccessible) // CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member3} (35) (inaccessible) -// CHECK-ACCESS: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )} (34) +// CHECK-ACCESS: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )} (79) // CHECK-ACCESS: ClassDecl:{TypedText Z}{Text ::} (75) -// CHECK-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} (34) +// CHECK-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} (79) class P { protected: @@ -76,14 +76,14 @@ } // CHECK-USING-INACCESSIBLE: FieldDecl:{ResultType int}{TypedText member} (35) (inaccessible) -// CHECK-USING-INACCESSIBLE: CXXMethod:{ResultType P &}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (34) +// CHECK-USING-INACCESSIBLE: CXXMethod:{ResultType P &}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (79) // CHECK-USING-INACCESSIBLE: ClassDecl:{TypedText P}{Text ::} (75) -// CHECK-USING-INACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~P}{LeftParen (}{RightParen )} (34) +// CHECK-USING-INACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~P}{LeftParen (}{RightParen )} (79) // CHECK-USING-ACCESSIBLE: FieldDecl:{ResultType int}{TypedText member} (35) -// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType Q &}{TypedText operator=}{LeftParen (}{Placeholder const Q &}{RightParen )} (34) -// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType P &}{Text P::}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (36) +// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType Q &}{TypedText operator=}{LeftParen (}{Placeholder const Q &}{RightParen )} (79) +// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType P &}{Text P::}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (81) // CHECK-USING-ACCESSIBLE: ClassDecl:{TypedText P}{Text ::} (77) // CHECK-USING-ACCESSIBLE: ClassDecl:{TypedText Q}{Text ::} (75) -// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{Informative P::}{TypedText ~P}{LeftParen (}{RightParen )} (36) -// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~Q}{LeftParen (}{RightParen )} (34) +// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{Informative P::}{TypedText ~P}{LeftParen (}{RightParen )} (81) +// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~Q}{LeftParen (}{RightParen )} (79) Index: cfe/trunk/test/Index/complete-cxx-inline-methods.cpp =================================================================== --- cfe/trunk/test/Index/complete-cxx-inline-methods.cpp +++ cfe/trunk/test/Index/complete-cxx-inline-methods.cpp @@ -25,11 +25,11 @@ // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s -// CHECK: CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34) +// CHECK: CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (79) // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75) // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35) // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35) -// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (34) +// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (79) // CHECK-NEXT: Completion contexts: // CHECK-NEXT: Dot member access // CHECK-NEXT: Container Kind: StructDecl Index: cfe/trunk/test/Index/complete-qualified.cpp =================================================================== --- cfe/trunk/test/Index/complete-qualified.cpp +++ cfe/trunk/test/Index/complete-qualified.cpp @@ -17,4 +17,4 @@ // CHECK-CC1: FieldDecl:{ResultType C}{TypedText c} (35) // CHECK-CC1: ClassDecl:{TypedText Foo} (35) // CHECK-CC1: CXXMethod:{ResultType Foo &}{TypedText operator=}{LeftParen (}{Placeholder const Foo &}{RightParen )} -// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (35) +// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (80) Index: cfe/trunk/test/Index/complete-with-annotations.cpp =================================================================== --- cfe/trunk/test/Index/complete-with-annotations.cpp +++ cfe/trunk/test/Index/complete-with-annotations.cpp @@ -17,7 +17,7 @@ // CHECK: FieldDecl:{ResultType int}{TypedText field} (35) ("three", "two", "one") // CHECK: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) ("some annotation") // CHECK: FieldDecl:{ResultType int}{TypedText member2} (35) ("another annotation", "some annotation") -// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (34) +// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (79) // CHECK: ClassDecl:{TypedText X}{Text ::} (75) -// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (34) +// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (79)