Index: lib/Sema/SemaCodeComplete.cpp =================================================================== --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -4822,7 +4822,7 @@ // it can be useful for global code completion which have information about // contexts/symbols that are not in the AST. if (SS.isInvalid()) { - CodeCompletionContext CC(CodeCompletionContext::CCC_Name); + CodeCompletionContext CC(CodeCompletionContext::CCC_Statement); CC.setCXXScopeSpecifier(SS); HandleCodeCompleteResults(this, CodeCompleter, CC, nullptr, 0); return; @@ -4840,7 +4840,7 @@ ResultBuilder Results(*this, CodeCompleter->getAllocator(), CodeCompleter->getCodeCompletionTUInfo(), - CodeCompletionContext::CCC_Name); + CodeCompletionContext::CCC_Statement); Results.EnterNewScope(); // The "template" keyword can follow "::" in the grammar, but only @@ -4880,7 +4880,7 @@ ResultBuilder Results(*this, CodeCompleter->getAllocator(), CodeCompleter->getCodeCompletionTUInfo(), - CodeCompletionContext::CCC_PotentiallyQualifiedName, + CodeCompletionContext::CCC_Statement, &ResultBuilder::IsNestedNameSpecifier); Results.EnterNewScope(); Index: test/CodeCompletion/ordinary-name.c =================================================================== --- test/CodeCompletion/ordinary-name.c +++ test/CodeCompletion/ordinary-name.c @@ -3,8 +3,9 @@ typedef struct t TYPEDEF; typedef struct t _TYPEDEF; void foo() { + int yar; int y; - // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:6:11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1-NOT: __INTEGER_TYPE // CHECK-CC1: _Imaginary // CHECK-CC1: _MyPrivateType @@ -16,3 +17,6 @@ // PR8744 // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:1:11 %s + + // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:7:8 %s -o - | FileCheck -allow-empty %s + // CHECK-NOT: yar