Index: lib/Sema/SemaCodeComplete.cpp =================================================================== --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -4747,7 +4747,12 @@ return; } - CodeCompleteExpression(S, VD->getType()); + CodeCompleteExpressionData Data; + Data.PreferredType = VD->getType(); + // Ignore VD to avoid completing the variable itself, e.g. in 'int foo = ^'. + Data.IgnoreDecls.push_back(VD); + + CodeCompleteExpression(S, Data); } void Sema::CodeCompleteReturn(Scope *S) { Index: test/CodeCompletion/ordinary-name-cxx11.cpp =================================================================== --- test/CodeCompletion/ordinary-name-cxx11.cpp +++ test/CodeCompletion/ordinary-name-cxx11.cpp @@ -197,7 +197,6 @@ // CHECK-CC4-NEXT: COMPLETION: volatile // CHECK-CC4-NEXT: COMPLETION: wchar_t // CHECK-CC4-NEXT: COMPLETION: X : X - // CHECK-CC4-NEXT: COMPLETION: y : [#int#]y // CHECK-CC4-NEXT: COMPLETION: z : [#void#]z(<#int#>) // RUN: %clang_cc1 -fsyntax-only -fno-rtti -code-completion-patterns -code-completion-at=%s:6:14 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-NO-RTTI %s Index: test/CodeCompletion/ordinary-name.cpp =================================================================== --- test/CodeCompletion/ordinary-name.cpp +++ test/CodeCompletion/ordinary-name.cpp @@ -171,7 +171,6 @@ // CHECK-CC4-NEXT: COMPLETION: volatile // CHECK-CC4-NEXT: COMPLETION: wchar_t // CHECK-CC4-NEXT: COMPLETION: X : X - // CHECK-CC4-NEXT: COMPLETION: y : [#int#]y // CHECK-CC4-NEXT: COMPLETION: z : [#void#]z(<#int#>) // RUN: %clang_cc1 -fsyntax-only -fno-rtti -code-completion-patterns -code-completion-at=%s:6:14 -std=gnu++98 %s -o - | FileCheck -check-prefix=CHECK-NO-RTTI %s Index: test/CodeCompletion/self-inits.cpp =================================================================== --- /dev/null +++ test/CodeCompletion/self-inits.cpp @@ -0,0 +1,3 @@ +int foo = 10; +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:1:11 %s -o - | FileCheck --check-prefix=CC1 %s +// CC1-NOT: foo Index: test/Index/complete-type-factors.m =================================================================== --- test/Index/complete-type-factors.m +++ test/Index/complete-type-factors.m @@ -39,7 +39,6 @@ // CHECK-CC1: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (25) // CHECK-CC1: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (32) // CHECK-CC1: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (32) -// CHECK-CC1: VarDecl:{ResultType int}{TypedText i} (8) // CHECK-CC1: ParmDecl:{ResultType int}{TypedText integer} (8) // CHECK-CC1: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (32) // CHECK-CC1: ParmDecl:{ResultType enum Priority}{TypedText priority} (17) @@ -48,7 +47,6 @@ // CHECK-CC1: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (25) // RUN: c-index-test -code-completion-at=%s:17:18 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (16) -// CHECK-CC2: VarDecl:{ResultType enum Color}{TypedText c} (8) // CHECK-CC2: ParmDecl:{ResultType enum Color}{TypedText color} (8) // CHECK-CC2: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (25) // CHECK-CC2: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (50)