diff --git a/clang-tools-extra/clangd/CodeComplete.h b/clang-tools-extra/clangd/CodeComplete.h --- a/clang-tools-extra/clangd/CodeComplete.h +++ b/clang-tools-extra/clangd/CodeComplete.h @@ -291,7 +291,7 @@ // For index-based completion, we only consider: // * symbols in namespaces or translation unit scopes (e.g. no class // members, no locals) -// * enum constants in unscoped enum decl (e.g. "red" in "enum {red};") +// * enum constants (both scoped and unscoped) // * primary templates (no specializations) // For the other cases, we let Clang do the completion because it does not // need any non-local information and it will be much better at following diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -2114,9 +2114,6 @@ }; return false; }; - auto InClassScope = [](const NamedDecl &ND) { - return ND.getDeclContext()->getDeclKind() == Decl::CXXRecord; - }; // We only complete symbol's name, which is the same as the name of the // *primary* template in case of template specializations. if (isExplicitTemplateSpecialization(&ND)) @@ -2135,8 +2132,8 @@ // Always index enum constants, even if they're not in the top level scope: // when // --all-scopes-completion is set, we'll want to complete those as well. - if (const auto *EnumDecl = dyn_cast(ND.getDeclContext())) - return (InTopLevelScope(*EnumDecl) || InClassScope(*EnumDecl)) && !EnumDecl->isScoped(); + if (llvm::isa(ND.getDeclContext())) + return true; return false; } diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp --- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1329,7 +1329,7 @@ AllOf(qName("Color"), forCodeCompletion(true)), AllOf(qName("Green"), forCodeCompletion(true)), AllOf(qName("Color2"), forCodeCompletion(true)), - AllOf(qName("Color2::Yellow"), forCodeCompletion(false)), + AllOf(qName("Color2::Yellow"), forCodeCompletion(true)), AllOf(qName("Color3"), forCodeCompletion(true)), AllOf(qName("Color3::Blue"), forCodeCompletion(true)), AllOf(qName("ns"), forCodeCompletion(true)),