[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk closed 
https://github.com/llvm/llvm-project/pull/147219
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/147219

>From a5e5e795e2b31295f781d2398e41f46785c0f18b Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Mon, 7 Jul 2025 02:52:01 +0300
Subject: [PATCH 1/2] [Clang] accept @tparam on variable template partial
 specializations

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/AST/Comment.cpp  |  8 
 clang/test/Sema/warn-documentation.cpp | 12 
 3 files changed, 22 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9a94c4bcd9980..d85c592b6d8bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -671,6 +671,8 @@ Improvements to Clang's diagnostics
   false positives in exception-heavy code, though only simple patterns
   are currently recognized.
 
+- Clang now accepts ``@tparam`` comments on variable template partial
+  specializations. (#GH144775)
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index d022c5c845ae6..08f860e2490ba 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -291,6 +291,14 @@ void DeclInfo::fill() {
 TemplateParameters = CTPSD->getTemplateParameters();
 break;
   }
+  case Decl::VarTemplatePartialSpecialization: {
+const VarTemplatePartialSpecializationDecl *VTPSD =
+cast(CommentDecl);
+Kind = VariableKind;
+TemplateKind = TemplatePartialSpecialization;
+TemplateParameters = VTPSD->getTemplateParameters();
+break;
+  }
   case Decl::ClassTemplateSpecialization:
 Kind = ClassKind;
 TemplateKind = TemplateSpecialization;
diff --git a/clang/test/Sema/warn-documentation.cpp 
b/clang/test/Sema/warn-documentation.cpp
index 4839bdff61795..0d1faa1b562fe 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -1524,3 +1524,15 @@ F &f = FF; ///< \return none
 // expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
 
 } // namespace PR42844
+
+#if __cplusplus >= 201402L
+namespace GH144775 {
+/// @brief primary template
+/// @tparam T type
+template  constexpr auto var = T{};
+
+/// @brief variable template partial specialization
+/// @tparam T type
+template  constexpr auto var = T{};
+} // namespace GH144775
+#endif

>From c487679a39ce10f50c348fa368926d1d566c5921 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Mon, 7 Jul 2025 17:29:30 +0300
Subject: [PATCH 2/2] use auto instead of an explicit type

---
 clang/lib/AST/Comment.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index 08f860e2490ba..cd73d2709dc65 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -292,8 +292,7 @@ void DeclInfo::fill() {
 break;
   }
   case Decl::VarTemplatePartialSpecialization: {
-const VarTemplatePartialSpecializationDecl *VTPSD =
-cast(CommentDecl);
+const auto *VTPSD = 
cast(CommentDecl);
 Kind = VariableKind;
 TemplateKind = TemplatePartialSpecialization;
 TemplateParameters = VTPSD->getTemplateParameters();

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


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Oleksandr T. via cfe-commits


@@ -291,6 +291,14 @@ void DeclInfo::fill() {
 TemplateParameters = CTPSD->getTemplateParameters();
 break;
   }
+  case Decl::VarTemplatePartialSpecialization: {
+const VarTemplatePartialSpecializationDecl *VTPSD =

a-tarasyuk wrote:

@AaronBallman thanks. Iv've updated to use `auto`

https://github.com/llvm/llvm-project/pull/147219
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/147219

>From a5e5e795e2b31295f781d2398e41f46785c0f18b Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Mon, 7 Jul 2025 02:52:01 +0300
Subject: [PATCH 1/2] [Clang] accept @tparam on variable template partial
 specializations

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/AST/Comment.cpp  |  8 
 clang/test/Sema/warn-documentation.cpp | 12 
 3 files changed, 22 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9a94c4bcd9980..d85c592b6d8bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -671,6 +671,8 @@ Improvements to Clang's diagnostics
   false positives in exception-heavy code, though only simple patterns
   are currently recognized.
 
+- Clang now accepts ``@tparam`` comments on variable template partial
+  specializations. (#GH144775)
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index d022c5c845ae6..08f860e2490ba 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -291,6 +291,14 @@ void DeclInfo::fill() {
 TemplateParameters = CTPSD->getTemplateParameters();
 break;
   }
+  case Decl::VarTemplatePartialSpecialization: {
+const VarTemplatePartialSpecializationDecl *VTPSD =
+cast(CommentDecl);
+Kind = VariableKind;
+TemplateKind = TemplatePartialSpecialization;
+TemplateParameters = VTPSD->getTemplateParameters();
+break;
+  }
   case Decl::ClassTemplateSpecialization:
 Kind = ClassKind;
 TemplateKind = TemplateSpecialization;
diff --git a/clang/test/Sema/warn-documentation.cpp 
b/clang/test/Sema/warn-documentation.cpp
index 4839bdff61795..0d1faa1b562fe 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -1524,3 +1524,15 @@ F &f = FF; ///< \return none
 // expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
 
 } // namespace PR42844
+
+#if __cplusplus >= 201402L
+namespace GH144775 {
+/// @brief primary template
+/// @tparam T type
+template  constexpr auto var = T{};
+
+/// @brief variable template partial specialization
+/// @tparam T type
+template  constexpr auto var = T{};
+} // namespace GH144775
+#endif

>From c487679a39ce10f50c348fa368926d1d566c5921 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Mon, 7 Jul 2025 17:29:30 +0300
Subject: [PATCH 2/2] use auto instead of an explicit type

---
 clang/lib/AST/Comment.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index 08f860e2490ba..cd73d2709dc65 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -292,8 +292,7 @@ void DeclInfo::fill() {
 break;
   }
   case Decl::VarTemplatePartialSpecialization: {
-const VarTemplatePartialSpecializationDecl *VTPSD =
-cast(CommentDecl);
+const auto *VTPSD = 
cast(CommentDecl);
 Kind = VariableKind;
 TemplateKind = TemplatePartialSpecialization;
 TemplateParameters = VTPSD->getTemplateParameters();

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


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Aaron Ballman via cfe-commits


@@ -291,6 +291,14 @@ void DeclInfo::fill() {
 TemplateParameters = CTPSD->getTemplateParameters();
 break;
   }
+  case Decl::VarTemplatePartialSpecialization: {
+const VarTemplatePartialSpecializationDecl *VTPSD =

AaronBallman wrote:

```suggestion
const auto *VTPSD =
```

https://github.com/llvm/llvm-project/pull/147219
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

LGTM, with a small nit. (Feel free to land once addressed, additional review 
not required.)

https://github.com/llvm/llvm-project/pull/147219
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman edited 
https://github.com/llvm/llvm-project/pull/147219
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-07 Thread Corentin Jabot via cfe-commits

https://github.com/cor3ntin approved this pull request.


https://github.com/llvm/llvm-project/pull/147219
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-06 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/147219

>From a5e5e795e2b31295f781d2398e41f46785c0f18b Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Mon, 7 Jul 2025 02:52:01 +0300
Subject: [PATCH] [Clang] accept @tparam on variable template partial
 specializations

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/AST/Comment.cpp  |  8 
 clang/test/Sema/warn-documentation.cpp | 12 
 3 files changed, 22 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9a94c4bcd9980..d85c592b6d8bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -671,6 +671,8 @@ Improvements to Clang's diagnostics
   false positives in exception-heavy code, though only simple patterns
   are currently recognized.
 
+- Clang now accepts ``@tparam`` comments on variable template partial
+  specializations. (#GH144775)
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index d022c5c845ae6..08f860e2490ba 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -291,6 +291,14 @@ void DeclInfo::fill() {
 TemplateParameters = CTPSD->getTemplateParameters();
 break;
   }
+  case Decl::VarTemplatePartialSpecialization: {
+const VarTemplatePartialSpecializationDecl *VTPSD =
+cast(CommentDecl);
+Kind = VariableKind;
+TemplateKind = TemplatePartialSpecialization;
+TemplateParameters = VTPSD->getTemplateParameters();
+break;
+  }
   case Decl::ClassTemplateSpecialization:
 Kind = ClassKind;
 TemplateKind = TemplateSpecialization;
diff --git a/clang/test/Sema/warn-documentation.cpp 
b/clang/test/Sema/warn-documentation.cpp
index 4839bdff61795..0d1faa1b562fe 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -1524,3 +1524,15 @@ F &f = FF; ///< \return none
 // expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
 
 } // namespace PR42844
+
+#if __cplusplus >= 201402L
+namespace GH144775 {
+/// @brief primary template
+/// @tparam T type
+template  constexpr auto var = T{};
+
+/// @brief variable template partial specialization
+/// @tparam T type
+template  constexpr auto var = T{};
+} // namespace GH144775
+#endif

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


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-06 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
clang/lib/AST/Comment.cpp clang/test/Sema/warn-documentation.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index 9fd4cc942..08f860e24 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -292,7 +292,8 @@ void DeclInfo::fill() {
 break;
   }
   case Decl::VarTemplatePartialSpecialization: {
-const VarTemplatePartialSpecializationDecl *VTPSD = 
cast(CommentDecl);
+const VarTemplatePartialSpecializationDecl *VTPSD =
+cast(CommentDecl);
 Kind = VariableKind;
 TemplateKind = TemplatePartialSpecialization;
 TemplateParameters = VTPSD->getTemplateParameters();

``




https://github.com/llvm/llvm-project/pull/147219
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)


Changes

Fixes #144775

--- 

This patch addresses a false-positive `-Wdocumentation` warning on `@tparam` comments attached to _variable template partial specializations_

---
Full diff: https://github.com/llvm/llvm-project/pull/147219.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/AST/Comment.cpp (+7) 
- (modified) clang/test/Sema/warn-documentation.cpp (+12) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9a94c4bcd9980..d85c592b6d8bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -671,6 +671,8 @@ Improvements to Clang's diagnostics
   false positives in exception-heavy code, though only simple patterns
   are currently recognized.
 
+- Clang now accepts ``@tparam`` comments on variable template partial
+  specializations. (#GH144775)
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index d022c5c845ae6..9fd4cc942e7b7 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -291,6 +291,13 @@ void DeclInfo::fill() {
 TemplateParameters = CTPSD->getTemplateParameters();
 break;
   }
+  case Decl::VarTemplatePartialSpecialization: {
+const VarTemplatePartialSpecializationDecl *VTPSD = 
cast(CommentDecl);
+Kind = VariableKind;
+TemplateKind = TemplatePartialSpecialization;
+TemplateParameters = VTPSD->getTemplateParameters();
+break;
+  }
   case Decl::ClassTemplateSpecialization:
 Kind = ClassKind;
 TemplateKind = TemplateSpecialization;
diff --git a/clang/test/Sema/warn-documentation.cpp 
b/clang/test/Sema/warn-documentation.cpp
index 4839bdff61795..0d1faa1b562fe 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -1524,3 +1524,15 @@ F &f = FF; ///< \return none
 // expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
 
 } // namespace PR42844
+
+#if __cplusplus >= 201402L
+namespace GH144775 {
+/// @brief primary template
+/// @tparam T type
+template  constexpr auto var = T{};
+
+/// @brief variable template partial specialization
+/// @tparam T type
+template  constexpr auto var = T{};
+} // namespace GH144775
+#endif

``




https://github.com/llvm/llvm-project/pull/147219
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] accept @tparam on variable template partial specializations (PR #147219)

2025-07-06 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk created 
https://github.com/llvm/llvm-project/pull/147219

Fixes #144775

--- 

This patch addresses a false-positive `-Wdocumentation` warning on `@tparam` 
comments attached to _variable template partial specializations_

>From 2c44c8bd3c2a49ba0a2cecdcadf5d08c0e9e3108 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Mon, 7 Jul 2025 02:40:43 +0300
Subject: [PATCH] [Clang] accept @tparam on variable template partial
 specializations

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/AST/Comment.cpp  |  7 +++
 clang/test/Sema/warn-documentation.cpp | 12 
 3 files changed, 21 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9a94c4bcd9980..d85c592b6d8bc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -671,6 +671,8 @@ Improvements to Clang's diagnostics
   false positives in exception-heavy code, though only simple patterns
   are currently recognized.
 
+- Clang now accepts ``@tparam`` comments on variable template partial
+  specializations. (#GH144775)
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index d022c5c845ae6..9fd4cc942e7b7 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -291,6 +291,13 @@ void DeclInfo::fill() {
 TemplateParameters = CTPSD->getTemplateParameters();
 break;
   }
+  case Decl::VarTemplatePartialSpecialization: {
+const VarTemplatePartialSpecializationDecl *VTPSD = 
cast(CommentDecl);
+Kind = VariableKind;
+TemplateKind = TemplatePartialSpecialization;
+TemplateParameters = VTPSD->getTemplateParameters();
+break;
+  }
   case Decl::ClassTemplateSpecialization:
 Kind = ClassKind;
 TemplateKind = TemplateSpecialization;
diff --git a/clang/test/Sema/warn-documentation.cpp 
b/clang/test/Sema/warn-documentation.cpp
index 4839bdff61795..0d1faa1b562fe 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -1524,3 +1524,15 @@ F &f = FF; ///< \return none
 // expected-warning@-1 {{'\return' command used in a comment that is not 
attached to a function or method declaration}}
 
 } // namespace PR42844
+
+#if __cplusplus >= 201402L
+namespace GH144775 {
+/// @brief primary template
+/// @tparam T type
+template  constexpr auto var = T{};
+
+/// @brief variable template partial specialization
+/// @tparam T type
+template  constexpr auto var = T{};
+} // namespace GH144775
+#endif

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