https://github.com/evelez7 updated 
https://github.com/llvm/llvm-project/pull/199800

>From 9268d433a28678edb08b4fe29a3e3d9fbd405f33 Mon Sep 17 00:00:00 2001
From: Erick Velez <[email protected]>
Date: Tue, 26 May 2026 17:32:39 -0700
Subject: [PATCH 1/4] [clang] Fix @tparam warnings for concept template
 parameters

`-Wdocumentation` would warn on `@tparam` commands for concepts even if the 
named
parameter existed. This patch fixes that by explicitly checking the
concept decl for template declarations.
---
 clang/lib/AST/CommentSema.cpp          | 12 +++++++++---
 clang/test/Sema/warn-documentation.cpp |  8 ++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index e74c7cb5ce605..156307e7abfd5 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -317,8 +317,13 @@ void 
Sema::actOnTParamCommandParamNameArg(TParamCommandComment *Command,
     return;
   }
 
-  const TemplateParameterList *TemplateParameters =
-      ThisDeclInfo->TemplateParameters;
+  const TemplateParameterList *TemplateParameters;
+  if (const auto *Concept =
+          dyn_cast_or_null<ConceptDecl>(ThisDeclInfo->CommentDecl))
+    TemplateParameters = Concept->getTemplateParameters();
+  else
+    TemplateParameters = ThisDeclInfo->TemplateParameters;
+
   SmallVector<unsigned, 2> Position;
   if (resolveTParamReference(Arg, TemplateParameters, &Position)) {
     Command->setPosition(copyArray(ArrayRef(Position)));
@@ -857,7 +862,8 @@ bool Sema::isTemplateOrSpecialization() {
     return false;
   if (!ThisDeclInfo->IsFilled)
     inspectThisDecl();
-  return ThisDeclInfo->getTemplateKind() != DeclInfo::NotTemplate;
+  return ThisDeclInfo->getTemplateKind() != DeclInfo::NotTemplate ||
+         isa<ConceptDecl>(ThisDeclInfo->CommentDecl);
 }
 
 bool Sema::isExplicitFunctionTemplateInstantiation() {
diff --git a/clang/test/Sema/warn-documentation.cpp 
b/clang/test/Sema/warn-documentation.cpp
index 24a4a22755a36..1076aa61266dc 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation 
-Wdocumentation-pedantic -verify %s
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation 
-Wdocumentation-pedantic -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdocumentation 
-Wdocumentation-pedantic -verify %s
 
 // This file contains lots of corner cases, so ensure that XML we generate is 
not invalid.
 // RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | 
FileCheck %s -check-prefix=WRONG
@@ -1544,5 +1545,12 @@ namespace GH64087
 template <typename T>
 void foo(){}
 
+#if __cplusplus >= 202002L
+/// @tparam T Derived class.
+/// @tparam TBase Base CRTP class.
+template <typename T, typename TBase>
+concept bar = true;
+#endif
+
 template void foo<bool>();
 } // namespace GH64087

>From 9713ed53e7e92da9c2e9fed0ee260167527f59da Mon Sep 17 00:00:00 2001
From: Erick Velez <[email protected]>
Date: Wed, 27 May 2026 08:20:08 -0700
Subject: [PATCH 2/4] add concept support to DeclInfo instead

---
 clang/include/clang/AST/Comment.h |  4 +++-
 clang/lib/AST/Comment.cpp         |  6 ++++++
 clang/lib/AST/CommentSema.cpp     | 10 ++--------
 clang/lib/Index/CommentToXML.cpp  |  4 ++++
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/clang/include/clang/AST/Comment.h 
b/clang/include/clang/AST/Comment.h
index 5ba95c8291d38..9ea86089373d5 100644
--- a/clang/include/clang/AST/Comment.h
+++ b/clang/include/clang/AST/Comment.h
@@ -1044,7 +1044,9 @@ struct DeclInfo {
     TypedefKind,
 
     /// An enumeration or scoped enumeration.
-    EnumKind
+    EnumKind,
+
+    ConceptKind
   };
 
   /// What kind of template specialization \c CommentDecl is.
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index 3ea7288231c97..a1c73f9ec179b 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -350,6 +350,12 @@ void DeclInfo::fill() {
   case Decl::Enum:
     Kind = EnumKind;
     break;
+  case Decl::Concept:
+    const ConceptDecl *Concept = cast<ConceptDecl>(CommentDecl);
+    Kind = ConceptKind;
+    TemplateKind = Template;
+    TemplateParameters = Concept->getTemplateParameters();
+    break;
   }
 
   // If the type is a typedef / using to something we consider a function,
diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 156307e7abfd5..efe53d294f1f9 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -317,12 +317,7 @@ void 
Sema::actOnTParamCommandParamNameArg(TParamCommandComment *Command,
     return;
   }
 
-  const TemplateParameterList *TemplateParameters;
-  if (const auto *Concept =
-          dyn_cast_or_null<ConceptDecl>(ThisDeclInfo->CommentDecl))
-    TemplateParameters = Concept->getTemplateParameters();
-  else
-    TemplateParameters = ThisDeclInfo->TemplateParameters;
+  const TemplateParameterList *TemplateParameters = 
ThisDeclInfo->TemplateParameters;
 
   SmallVector<unsigned, 2> Position;
   if (resolveTParamReference(Arg, TemplateParameters, &Position)) {
@@ -862,8 +857,7 @@ bool Sema::isTemplateOrSpecialization() {
     return false;
   if (!ThisDeclInfo->IsFilled)
     inspectThisDecl();
-  return ThisDeclInfo->getTemplateKind() != DeclInfo::NotTemplate ||
-         isa<ConceptDecl>(ThisDeclInfo->CommentDecl);
+  return ThisDeclInfo->getTemplateKind() != DeclInfo::NotTemplate;
 }
 
 bool Sema::isExplicitFunctionTemplateInstantiation() {
diff --git a/clang/lib/Index/CommentToXML.cpp b/clang/lib/Index/CommentToXML.cpp
index f17c0ff868314..2c5c13d67c3cf 100644
--- a/clang/lib/Index/CommentToXML.cpp
+++ b/clang/lib/Index/CommentToXML.cpp
@@ -893,6 +893,10 @@ void CommentASTToXMLConverter::visitFullComment(const 
FullComment *C) {
       RootEndTag = "</Enum>";
       Result << "<Enum";
       break;
+    case DeclInfo::ConceptKind:
+      RootEndTag = "</Concept";
+      Result << "<Concept";
+      break;
     }
 
     {

>From 7a422d6198221b4e072e57a2c85bfdb277e373a3 Mon Sep 17 00:00:00 2001
From: Erick Velez <[email protected]>
Date: Wed, 27 May 2026 08:23:19 -0700
Subject: [PATCH 3/4] git clang-format

---
 clang/lib/AST/CommentSema.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index efe53d294f1f9..02fec29e698c2 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -317,7 +317,8 @@ void 
Sema::actOnTParamCommandParamNameArg(TParamCommandComment *Command,
     return;
   }
 
-  const TemplateParameterList *TemplateParameters = 
ThisDeclInfo->TemplateParameters;
+  const TemplateParameterList *TemplateParameters =
+      ThisDeclInfo->TemplateParameters;
 
   SmallVector<unsigned, 2> Position;
   if (resolveTParamReference(Arg, TemplateParameters, &Position)) {

>From f68d6535edde0a6e410a0ed9d5f4e3bfbdb5702c Mon Sep 17 00:00:00 2001
From: Erick Velez <[email protected]>
Date: Fri, 29 May 2026 00:12:45 -0700
Subject: [PATCH 4/4] fix some typos and add release note

---
 clang/docs/ReleaseNotes.rst            | 3 +++
 clang/lib/AST/CommentSema.cpp          | 1 -
 clang/lib/Index/CommentToXML.cpp       | 2 +-
 clang/test/Sema/warn-documentation.cpp | 2 +-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b9a611015813..c5e71cd6fee42 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -448,6 +448,9 @@ Improvements to Clang's diagnostics
 - Fixed bug in ``-Wdocumentation`` so that it correctly handles explicit
   function template instantiations (#64087).
 
+- Fixed concept template parameters not being recognized in ``-Wdocumentation``
+  when mentioned in tparam comments. (#GH64087)
+
 - ``-Wunused-but-set-variable`` now diagnoses file-scope variables with
   internal linkage (``static`` storage class) that are assigned but never used.
   This new coverage is added under the subgroup ``-Wunused-but-set-global``,
diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 02fec29e698c2..e74c7cb5ce605 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -319,7 +319,6 @@ void 
Sema::actOnTParamCommandParamNameArg(TParamCommandComment *Command,
 
   const TemplateParameterList *TemplateParameters =
       ThisDeclInfo->TemplateParameters;
-
   SmallVector<unsigned, 2> Position;
   if (resolveTParamReference(Arg, TemplateParameters, &Position)) {
     Command->setPosition(copyArray(ArrayRef(Position)));
diff --git a/clang/lib/Index/CommentToXML.cpp b/clang/lib/Index/CommentToXML.cpp
index 2c5c13d67c3cf..c407a4ef64914 100644
--- a/clang/lib/Index/CommentToXML.cpp
+++ b/clang/lib/Index/CommentToXML.cpp
@@ -894,7 +894,7 @@ void CommentASTToXMLConverter::visitFullComment(const 
FullComment *C) {
       Result << "<Enum";
       break;
     case DeclInfo::ConceptKind:
-      RootEndTag = "</Concept";
+      RootEndTag = "</Concept>";
       Result << "<Concept";
       break;
     }
diff --git a/clang/test/Sema/warn-documentation.cpp 
b/clang/test/Sema/warn-documentation.cpp
index 1076aa61266dc..e64f68a8797ee 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -1547,7 +1547,7 @@ void foo(){}
 
 #if __cplusplus >= 202002L
 /// @tparam T Derived class.
-/// @tparam TBase Base CRTP class.
+/// @tparam TBase Base class.
 template <typename T, typename TBase>
 concept bar = true;
 #endif

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to