[clang] [clang-tools-extra] [clangd] Collect comments from function definitions into the index (PR #67802)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 8 23:52:01 PDT 2024


================
@@ -1069,6 +1071,27 @@ void SymbolCollector::addDefinition(const NamedDecl &ND,
   Symbol S = DeclSym;
   // FIXME: use the result to filter out symbols.
   S.Definition = *DefLoc;
+
+  std::string DocComment;
+  std::string Documentation;
+  if (!(S.Flags & Symbol::HasDocComment) &&
----------------
HighCommander4 wrote:

It's possible for both `addDeclaration()` and `addDefinition()` to be called for a given `Decl*` (if e.g. the definition is the first encountered declaration).

In such cases, if `addDeclaration()` failed to find a doc comment, we should probably avoid trying again in `addDefinition()` (since that will fail too and just run `CreateCodeCompletionString()` and `getDocComment()` needlessly).

https://github.com/llvm/llvm-project/pull/67802


More information about the cfe-commits mailing list