[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
Thu Sep 12 18:15:46 PDT 2024


================
@@ -635,17 +635,20 @@ bool SymbolCollector::handleDeclOccurrence(
     return true;
 
   const Symbol *BasicSymbol = Symbols.find(ID);
-  if (isPreferredDeclaration(*OriginalDecl, Roles))
+  bool SkipDocCheckInDef = false;
+  if (isPreferredDeclaration(*OriginalDecl, Roles)) {
     // If OriginalDecl is preferred, replace/create the existing canonical
     // declaration (e.g. a class forward declaration). There should be at most
     // one duplicate as we expect to see only one preferred declaration per
     // TU, because in practice they are definitions.
     BasicSymbol = addDeclaration(*OriginalDecl, std::move(ID), IsMainFileOnly);
-  else if (!BasicSymbol || DeclIsCanonical)
+    SkipDocCheckInDef = true;
+  } else if (!BasicSymbol || DeclIsCanonical) {
     BasicSymbol = addDeclaration(*ND, std::move(ID), IsMainFileOnly);
----------------
HighCommander4 wrote:

I think we want `SkipDocCheckInDef = true` in this branch as well. This is actually the more common case that will be hit, for first declarations which are also definitions (`DeclIsCanonical` is true).

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


More information about the cfe-commits mailing list