[clang] [clang][AST] Expose Doxygen comment groups to AST consumers (PR #245957)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 25 02:32:40 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Nikolai Beck (nbeck-SMT)

<details>
<summary>Changes</summary>

Doxygen grouping markers (\{ / @{ and \} / @}) and the grouping commands that name them (\name, \defgroup, \addtogroup, \weakgroup) were not visible in the AST, so tools could not tell which group a declaration belongs to.

Add a lazily computed, position-based index of groups built from the raw documentation comments of a file:

- RawCommentList::computeDocCommentGroups lexes the documentation comments with the comment lexer and pairs the open/close markers. Markers in \code blocks, escaped backslashes and ordinary comments are ignored, unmatched closing markers are dropped and unclosed groups stay open to the end of the file.
- ASTContext::getDocCommentGroupsInFile caches the groups per file and recomputes them when the comment list changes (including comments loaded from a PCH).
- ASTContext::getDocCommentGroupForDecl returns the innermost group around a declaration. Members of a record only belong to groups opened inside that record; locals and parameters are never grouped.
- -ast-dump and -ast-dump=json print the group chain of a declaration as a DocCommentGroup child node.

Fixes #<!-- -->123582

---

Patch is 32.63 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/245957.diff


13 Files Affected:

- (modified) clang/docs/ReleaseNotes.md (+6) 
- (modified) clang/include/clang/AST/ASTContext.h (+27) 
- (modified) clang/include/clang/AST/ASTNodeTraverser.h (+14) 
- (modified) clang/include/clang/AST/JSONNodeDumper.h (+1) 
- (modified) clang/include/clang/AST/RawCommentList.h (+87-1) 
- (modified) clang/include/clang/AST/TextNodeDumper.h (+2) 
- (modified) clang/lib/AST/ASTContext.cpp (+89) 
- (modified) clang/lib/AST/JSONNodeDumper.cpp (+13) 
- (modified) clang/lib/AST/RawCommentList.cpp (+143) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+16) 
- (added) clang/test/AST/ast-dump-comment-groups.cpp (+76) 
- (modified) clang/unittests/AST/CMakeLists.txt (+1) 
- (added) clang/unittests/AST/DocCommentGroupsTest.cpp (+328) 


``````````diff
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 006b643e582342..88901167e0a76c 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -211,6 +211,12 @@ features cannot lower the translation-unit ABI level;
 - The AST printer (`-ast-print`) now prints a floating-point literal as the
   shortest decimal form that round-trips to the same value. For example,
   `3.14` printed as `3.1400000000000001` before and prints as `3.14` now.
+- `-ast-dump` and `-ast-dump=json` now show a `DocCommentGroup` child for a
+  declaration inside a Doxygen group, that is between `\{` (or `@{`) and `\}`
+  (or `@}`) markers in documentation comments, together with the enclosing
+  groups. The new `ASTContext::getDocCommentGroupForDecl` and
+  `ASTContext::getDocCommentGroupsInFile` give tools such as clang-doc and
+  clangd the same information. (#GH123582)
 
 ### Clang Frontend Potentially Breaking Changes
 
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 9ad16898b32563..c862cb1182db4c 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1079,6 +1079,18 @@ class ASTContext : public RefCountedBase<ASTContext> {
   /// redeclaration.
   mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
 
+  /// Doxygen groups of a file, and the state of the file's comment list they
+  /// were computed from.
+  struct DocCommentGroupsInFile {
+    size_t NumComments = 0;
+    SourceLocation LastCommentEnd;
+    SmallVector<const DocCommentGroup *, 0> Groups;
+  };
+
+  /// Mapping from file to its Doxygen groups. Populated lazily and recomputed
+  /// when comments were added to the file since.
+  mutable llvm::DenseMap<FileID, DocCommentGroupsInFile> DocCommentGroups;
+
   /// Attaches \p Comment to \p Original (a declaration or macro), and to its
   /// redeclaration chain when \p Original is a declaration. Removes the
   /// redeclaration chain from the set of commentless chains.
@@ -1147,6 +1159,21 @@ class ASTContext : public RefCountedBase<ASTContext> {
   /// redeclarations of the declaration.
   comments::FullComment *getLocalCommentForDeclUncached(const Decl *D) const;
 
+  /// Return the Doxygen groups delimited by \c \\{ and \c \\} markers in the
+  /// documentation comments of \p File, ordered by their opening markers.
+  ///
+  /// The groups are computed on the first request for a file and cached.
+  ArrayRef<const DocCommentGroup *>
+  getDocCommentGroupsInFile(FileID File) const;
+
+  /// Return the innermost Doxygen group that encloses \p D, or nullptr.
+  ///
+  /// A declaration belongs to a group if it starts between the group's
+  /// opening and closing markers. A member of a class, function or other
+  /// non-namespace context only belongs to groups opened inside that context,
+  /// so a group around a class does not contain the class's members.
+  const DocCommentGroup *getDocCommentGroupForDecl(const Decl *D) const;
+
   comments::FullComment *cloneFullComment(comments::FullComment *FC,
                                          const Decl *D) const;
 
diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h
index e3314e99d9ad69..ad2a256ceba4eb 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -44,6 +44,7 @@ struct {
   template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild);
 
   void Visit(const comments::Comment *C, const comments::FullComment *FC);
+  void Visit(const DocCommentGroup *G);
   void Visit(const Attr *A);
   void Visit(const TemplateArgument &TA, SourceRange R = {},
              const Decl *From = nullptr, StringRef Label = {});
@@ -119,6 +120,10 @@ class ASTNodeTraverser
               D->getASTContext().getLocalCommentForDeclUncached(D))
         Visit(Comment, Comment);
 
+      if (const DocCommentGroup *Group =
+              D->getASTContext().getDocCommentGroupForDecl(D))
+        Visit(Group);
+
       // Decls within functions are visited by the body.
       if (!isa<FunctionDecl, ObjCMethodDecl, BlockDecl>(*D)) {
         if (Traversal != TK_AsIs) {
@@ -312,6 +317,15 @@ class ASTNodeTraverser
     });
   }
 
+  /// Visits a Doxygen group and, as its child, the group enclosing it.
+  void Visit(const DocCommentGroup *G) {
+    getNodeDelegate().AddChild([=] {
+      getNodeDelegate().Visit(G);
+      if (const DocCommentGroup *Parent = G->getParent())
+        Visit(Parent);
+    });
+  }
+
   void Visit(const DynTypedNode &N) {
     // FIXME: Improve this with a switch or a visitor pattern.
     if (const auto *D = N.get<Decl>())
diff --git a/clang/include/clang/AST/JSONNodeDumper.h b/clang/include/clang/AST/JSONNodeDumper.h
index 679ce4e4815ae8..f355b82d963929 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -201,6 +201,7 @@ class JSONNodeDumper
   void Visit(TypeLoc TL);
 
   void Visit(const comments::Comment *C, const comments::FullComment *FC);
+  void Visit(const DocCommentGroup *G);
   void Visit(const TemplateArgument &TA, SourceRange R = {},
              const Decl *From = nullptr, StringRef Label = {});
   void Visit(const CXXCtorInitializer *Init);
diff --git a/clang/include/clang/AST/RawCommentList.h b/clang/include/clang/AST/RawCommentList.h
index 3e4567b546a71d..7dc21348aa3ebc 100644
--- a/clang/include/clang/AST/RawCommentList.h
+++ b/clang/include/clang/AST/RawCommentList.h
@@ -13,6 +13,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Allocator.h"
 #include <map>
 
@@ -26,7 +27,8 @@ class Preprocessor;
 class SourceManager;
 
 namespace comments {
-  class FullComment;
+class CommandTraits;
+class FullComment;
 } // end namespace comments
 
 class RawComment {
@@ -207,6 +209,82 @@ class RawComment {
   friend class ASTReader;
 };
 
+/// A Doxygen group opened by a \c \\{ (or \c \@{) marker and closed by a
+/// \c \\} (or \c \@}) marker in documentation comments, for example:
+/// \code
+///   /// \name Accessors
+///   /// \{
+///   int getX() const;
+///   int getY() const;
+///   /// \}
+/// \endcode
+///
+/// Groups are computed from the documentation comments of a file, using only
+/// the positions of the markers. A group can be nested in another group.
+class DocCommentGroup {
+public:
+  enum GroupKind {
+    /// An opening marker without a grouping command before it in the same
+    /// comment.
+    GK_Unnamed,
+    /// \c \\name followed by an opening marker (a Doxygen member group).
+    GK_Member,
+    /// \c \\defgroup followed by an opening marker.
+    GK_DefGroup,
+    /// \c \\addtogroup followed by an opening marker.
+    GK_AddToGroup,
+    /// \c \\weakgroup followed by an opening marker.
+    GK_WeakGroup
+  };
+
+  DocCommentGroup(GroupKind Kind, StringRef Name, StringRef Title,
+                  SourceLocation OpenLoc, const DocCommentGroup *Parent)
+      : Kind(Kind), Name(Name), Title(Title), OpenLoc(OpenLoc), Parent(Parent) {
+  }
+
+  GroupKind getKind() const { return Kind; }
+
+  /// Returns the spelling of the grouping command for this kind of group
+  /// ("name", "defgroup", "addtogroup", "weakgroup"), or "unnamed".
+  StringRef getKindName() const;
+
+  /// For \c \\name, the header text. For \c \\defgroup, \c \\addtogroup and
+  /// \c \\weakgroup, the group identifier. Empty for unnamed groups.
+  StringRef getName() const { return Name; }
+
+  /// For \c \\defgroup, \c \\addtogroup and \c \\weakgroup, the optional
+  /// title after the group identifier. Empty otherwise.
+  StringRef getTitle() const { return Title; }
+
+  /// Location of the opening marker.
+  SourceLocation getOpenLoc() const { return OpenLoc; }
+
+  /// Location of the closing marker, or an invalid location if the group is
+  /// not closed before the end of the file.
+  SourceLocation getCloseLoc() const { return CloseLoc; }
+
+  bool isTerminated() const { return CloseLoc.isValid(); }
+
+  /// Range from the opening marker to the closing marker, or only the
+  /// opening marker if the group is not terminated.
+  SourceRange getSourceRange() const LLVM_READONLY {
+    return SourceRange(OpenLoc, isTerminated() ? CloseLoc : OpenLoc);
+  }
+
+  /// The group that encloses this group, if any.
+  const DocCommentGroup *getParent() const { return Parent; }
+
+  void setCloseLoc(SourceLocation Loc) { CloseLoc = Loc; }
+
+private:
+  GroupKind Kind;
+  StringRef Name;
+  StringRef Title;
+  SourceLocation OpenLoc;
+  SourceLocation CloseLoc;
+  const DocCommentGroup *Parent;
+};
+
 /// This class represents all comments included in the translation unit,
 /// sorted in order of appearance in the translation unit.
 class RawCommentList {
@@ -226,6 +304,14 @@ class RawCommentList {
                                unsigned Offset) const;
   unsigned getCommentEndOffset(RawComment *C) const;
 
+  /// Computes the Doxygen groups delimited by \c \\{ and \c \\} markers in
+  /// the documentation comments of \p File, ordered by their opening
+  /// markers. Unmatched closing markers are ignored. The groups and their
+  /// strings are allocated in \p Allocator.
+  SmallVector<const DocCommentGroup *, 0>
+  computeDocCommentGroups(FileID File, const comments::CommandTraits &Traits,
+                          llvm::BumpPtrAllocator &Allocator) const;
+
 private:
   SourceManager &SourceMgr;
   // mapping: FileId -> comment begin offset -> comment
diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h
index 592aa2f1bc9427..5c3af946991501 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -170,6 +170,8 @@ class TextNodeDumper
 
   void Visit(const comments::Comment *C, const comments::FullComment *FC);
 
+  void Visit(const DocCommentGroup *G);
+
   void Visit(const Attr *A);
 
   void Visit(const TemplateArgument &TA, SourceRange R,
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 3c46873c41359f..d2a1be23050ea7 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -584,6 +584,95 @@ comments::FullComment *ASTContext::getLocalCommentForDeclUncached(const Decl *D)
   return RC ? RC->parse(*this, nullptr, D) : nullptr;
 }
 
+ArrayRef<const DocCommentGroup *>
+ASTContext::getDocCommentGroupsInFile(FileID File) const {
+  if (File.isInvalid())
+    return {};
+
+  if (ExternalSource && !CommentsLoaded) {
+    ExternalSource->ReadComments();
+    CommentsLoaded = true;
+  }
+
+  const std::map<unsigned, RawComment *> *CommentsInFile =
+      Comments.getCommentsInFile(File);
+  if (!CommentsInFile || CommentsInFile->empty())
+    return {};
+
+  // Comments are added while parsing, and the last one can grow when the next
+  // comment is merged into it, so recompute when either has changed.
+  const size_t NumComments = CommentsInFile->size();
+  const SourceLocation LastCommentEnd =
+      CommentsInFile->rbegin()->second->getEndLoc();
+
+  auto [It, Inserted] = DocCommentGroups.try_emplace(File);
+  DocCommentGroupsInFile &Entry = It->second;
+  if (Inserted || Entry.NumComments != NumComments ||
+      Entry.LastCommentEnd != LastCommentEnd) {
+    Entry.NumComments = NumComments;
+    Entry.LastCommentEnd = LastCommentEnd;
+    Entry.Groups = Comments.computeDocCommentGroups(
+        File, getCommentCommandTraits(), BumpAlloc);
+  }
+  return Entry.Groups;
+}
+
+const DocCommentGroup *
+ASTContext::getDocCommentGroupForDecl(const Decl *D) const {
+  if (!D || D->isImplicit())
+    return nullptr;
+  D = &adjustDeclToTemplate(*D);
+
+  auto GetFileLoc = [this](const Decl *D) -> std::optional<FileIDAndOffset> {
+    SourceLocation Loc = D->getBeginLoc();
+    if (Loc.isInvalid())
+      Loc = D->getLocation();
+    if (Loc.isInvalid())
+      return std::nullopt;
+    return SourceMgr.getDecomposedLoc(SourceMgr.getExpansionLoc(Loc));
+  };
+
+  std::optional<FileIDAndOffset> DeclLoc = GetFileLoc(D);
+  if (!DeclLoc)
+    return nullptr;
+  ArrayRef<const DocCommentGroup *> Groups =
+      getDocCommentGroupsInFile(DeclLoc->first);
+
+  // Groups are ordered by their opening markers and nest properly, so the
+  // last group that opens before the declaration and is not yet closed is the
+  // innermost enclosing one.
+  const DocCommentGroup *Innermost = nullptr;
+  unsigned InnermostOpenOffset = 0;
+  for (const DocCommentGroup *G : Groups) {
+    unsigned OpenOffset = SourceMgr.getFileOffset(G->getOpenLoc());
+    if (OpenOffset >= DeclLoc->second)
+      break;
+    if (G->isTerminated() &&
+        SourceMgr.getFileOffset(G->getCloseLoc()) < DeclLoc->second)
+      continue;
+    Innermost = G;
+    InnermostOpenOffset = OpenOffset;
+  }
+  if (!Innermost)
+    return nullptr;
+
+  // A declaration inside a class, function, enumeration or similar context
+  // only belongs to groups opened inside that context. Namespaces, linkage
+  // specifications and export declarations do not limit groups.
+  const DeclContext *DC = D->getDeclContext();
+  while (DC && isa<LinkageSpecDecl, ExportDecl>(DC))
+    DC = DC->getParent();
+  if (DC && !DC->isFileContext()) {
+    std::optional<FileIDAndOffset> OwnerLoc = GetFileLoc(cast<Decl>(DC));
+    // Outer groups open even earlier than the innermost one, so none of them
+    // can be inside the owner either.
+    if (!OwnerLoc || OwnerLoc->first != DeclLoc->first ||
+        InnermostOpenOffset <= OwnerLoc->second)
+      return nullptr;
+  }
+  return Innermost;
+}
+
 comments::FullComment *ASTContext::getCommentForDecl(
                                               const Decl *D,
                                               const Preprocessor *PP) const {
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index 97d67914e02ddd..2697d50dd827ad 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -160,6 +160,19 @@ void JSONNodeDumper::Visit(const comments::Comment *C,
   InnerCommentVisitor::visit(C, FC);
 }
 
+void JSONNodeDumper::Visit(const DocCommentGroup *G) {
+  JOS.attribute("id", createPointerRepresentation(G));
+  JOS.attribute("kind", "DocCommentGroup");
+  JOS.attributeObject("range",
+                      [G, this] { writeSourceRange(G->getSourceRange()); });
+  JOS.attribute("groupKind", G->getKindName());
+  if (!G->getName().empty())
+    JOS.attribute("name", G->getName());
+  if (!G->getTitle().empty())
+    JOS.attribute("title", G->getTitle());
+  attributeOnlyIfTrue("unterminated", !G->isTerminated());
+}
+
 void JSONNodeDumper::Visit(const TemplateArgument &TA, SourceRange R,
                            const Decl *From, StringRef Label) {
   JOS.attribute("kind", "TemplateArgument");
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index 6379a2a1fe6bde..6c25646bdc0785 100644
--- a/clang/lib/AST/RawCommentList.cpp
+++ b/clang/lib/AST/RawCommentList.cpp
@@ -15,7 +15,12 @@
 #include "clang/AST/CommentParser.h"
 #include "clang/AST/CommentSema.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Allocator.h"
+#include <optional>
 
 using namespace clang;
 
@@ -357,6 +362,144 @@ unsigned RawCommentList::getCommentEndOffset(RawComment *C) const {
   return Offset;
 }
 
+StringRef DocCommentGroup::getKindName() const {
+  switch (Kind) {
+  case GK_Unnamed:
+    return "unnamed";
+  case GK_Member:
+    return "name";
+  case GK_DefGroup:
+    return "defgroup";
+  case GK_AddToGroup:
+    return "addtogroup";
+  case GK_WeakGroup:
+    return "weakgroup";
+  }
+  llvm_unreachable("unknown DocCommentGroup kind");
+}
+
+/// Maps a grouping command to the kind of group an opening marker after it
+/// creates.
+static std::optional<DocCommentGroup::GroupKind>
+getGroupKindForCommand(StringRef CommandName) {
+  return llvm::StringSwitch<std::optional<DocCommentGroup::GroupKind>>(
+             CommandName)
+      .Case("name", DocCommentGroup::GK_Member)
+      .Case("defgroup", DocCommentGroup::GK_DefGroup)
+      .Case("addtogroup", DocCommentGroup::GK_AddToGroup)
+      .Case("weakgroup", DocCommentGroup::GK_WeakGroup)
+      .Default(std::nullopt);
+}
+
+SmallVector<const DocCommentGroup *, 0> RawCommentList::computeDocCommentGroups(
+    FileID File, const comments::CommandTraits &Traits,
+    llvm::BumpPtrAllocator &Allocator) const {
+  SmallVector<const DocCommentGroup *, 0> Groups;
+  const std::map<unsigned, RawComment *> *CommentsInFile =
+      getCommentsInFile(File);
+  if (!CommentsInFile)
+    return Groups;
+
+  // The scan lexes comments that are not attached to any declaration, so
+  // their diagnostics (for example, unknown commands) would be new. Send them
+  // to a private engine that drops them.
+  DiagnosticOptions DiagOpts;
+  DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts,
+                          new IgnoringDiagConsumer());
+  llvm::BumpPtrAllocator ScratchAllocator;
+
+  SmallVector<DocCommentGroup *, 4> OpenGroups;
+  for (const auto &[Offset, RC] : *CommentsInFile) {
+    if (!RC->isDocumentation())
+      continue;
+    StringRef RawText = RC->getRawText(SourceMgr);
+    if (RawText.find_first_of("{}") == StringRef::npos)
+      continue;
+
+    comments::Lexer L(ScratchAllocator, Diags, Traits, RC->getBeginLoc(),
+                      RawText.begin(), RawText.end());
+
+    // The most recent grouping command in this comment that no opening
+    // marker used yet.
+    std::optional<DocCommentGroup::GroupKind> PendingKind;
+    StringRef PendingText;
+    bool ExpectGroupText = false;
+
+    // A one-character "\" or "@" text token directly before the current
+    // token. The lexer produces one when a backslash or at sign is not
+    // followed by a command name, as in "\{" and "@}". Escaped backslashes
+    // ("\\") produce a two-character token and are not markers.
+    std::optional<SourceLocation> MarkerLoc;
+
+    comments::Token Tok;
+    do {
+      L.lex(Tok);
+      std::optional<SourceLocation> PrevMarkerLoc = MarkerLoc;
+      MarkerLoc.reset();
+
+      switch (Tok.getKind()) {
+      case comments::tok::verbatim_line_name:
+        // Other verbatim line commands, such as \ingroup, leave a pending
+        // grouping command in place.
+        ExpectGroupText = false;
+        if (auto Kind = getGroupKindForCommand(
+                Traits.getCommandInfo(Tok.getVerbatimLineID())->Name)) {
+          PendingKind = Kind;
+          PendingText = StringRef();
+          ExpectGroupText = true;
+        }
+        continue;
+
+      case comments::tok::verbatim_line_text:
+        if (ExpectGroupText)
+          PendingText = Tok.getVerbatimLineText().trim();
+        ExpectGroupText = false;
+        continue;
+
+      case comments::tok::text: {
+        StringRef Text = Tok.getText();
+        if (Tok.getLength() == 1 && (Text == "\\" || Text == "@")) {
+          MarkerLoc = Tok.getLocation();
+          continue;
+        }
+        if (!PrevMarkerLoc || Text.empty())
+          continue;
+
+        if (Text.front() == '{') {
+          DocCommentGroup::GroupKind Kind = DocCommentGroup::GK_Unnamed;
+          StringRef Name, Title;
+          if (PendingKind) {
+            Kind = *PendingKind;
+            if (Kind == DocCommentGroup::GK_Member) {
+              Name = PendingText;
+            } else {
+              size_t IdEnd = PendingText.find_first_of(" \t");
+              Name = PendingText.substr(0, IdEnd);
+              Title = PendingText.substr(Name.size()).trim();
+            }
+            PendingKind.reset();
+          }
+          auto *G = new (Allocator) DocCommentGroup(
+              Kind, Name.copy(Allocator), Title.copy(Allocator), *PrevMarkerLoc,
+              OpenGroups.empty() ? nullptr : OpenGroups.back());
+          Groups.push_back(G);
+          OpenGroups.push_back(G);
+        } else if (Text.front() == '}' && !OpenGroups.empty()) {
+          OpenGroups.pop_back_val()->setCloseLoc(*PrevMarkerLoc);
+        }
+        continue;
+      }
+
+      default:
+        ExpectGroupText = false;
+        continue;
+      }
+    } while (Tok.isNot(comments::to...
[truncated]

``````````

</details>


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


More information about the cfe-commits mailing list