diff --git a/clang-tools-extra/clangd/CodeLens.cpp b/clang-tools-extra/clangd/CodeLens.cpp --- a/clang-tools-extra/clangd/CodeLens.cpp +++ b/clang-tools-extra/clangd/CodeLens.cpp @@ -81,13 +81,14 @@ CodeLensArgument Sub, Super; if (auto *CXXRD = dyn_cast(D)) { if (!CXXRD->isEffectivelyFinal()) { - Sub.locations = - - lookupIndex(Index, Limit, Path, D, RelationKind::BaseOf); + Sub.locations = lookupIndex(Index, Limit, Path, D, RelationKind::BaseOf); } - for (const auto *P : typeParents(CXXRD)) { - if (auto Loc = declToLocation(P->getCanonicalDecl())) - Super.locations.emplace_back(*Loc); + // bases codelens is only useful on forward decls + if (!CXXRD->isThisDeclarationADefinition()) { + for (const auto *P : typeParents(CXXRD)) { + if (auto Loc = declToLocation(P->getCanonicalDecl())) + Super.locations.emplace_back(*Loc); + } } } else if (auto *CXXMD = dyn_cast(D)) { if (CXXMD->isVirtual()) { @@ -105,7 +106,7 @@ Super.uri = std::string(Path); Command Cmd; Cmd.command = std::string(CodeAction::SHOW_REFERENCES); - Cmd.title = std::to_string(Count) + " base"; + Cmd.title = std::to_string(Count) + " base(s)"; Cmd.argument = std::move(Super); Results.emplace_back(CodeLens{Range, std::move(Cmd), None}); } @@ -157,7 +158,7 @@ for (auto &Ref : Refs) { Arg.locations.emplace_back(std::move(Ref.Loc)); } - Cmd.title = std::to_string(Refs.size()) + " references"; + Cmd.title = std::to_string(Refs.size()) + " ref(s)"; Cmd.argument = std::move(Arg); return CodeLens{Params.range, std::move(Cmd), None}; }