Author: Oleksandr T. Date: 2025-07-07T18:27:08+03:00 New Revision: 28649f2117426df30bf978c1531cd92be05d3865
URL: https://github.com/llvm/llvm-project/commit/28649f2117426df30bf978c1531cd92be05d3865 DIFF: https://github.com/llvm/llvm-project/commit/28649f2117426df30bf978c1531cd92be05d3865.diff LOG: [Clang] accept @tparam on variable template partial specializations (#147219) Fixes #144775 --- This patch addresses a false-positive `-Wdocumentation` warning on `@tparam` comments attached to _variable template partial specializations_ Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/AST/Comment.cpp clang/test/Sema/warn-documentation.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index fddfc36d302b5..581338924943b 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -675,6 +675,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..cd73d2709dc65 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 auto *VTPSD = cast<VarTemplatePartialSpecializationDecl>(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 <class T, class = void> constexpr auto var = T{}; + +/// @brief variable template partial specialization +/// @tparam T type +template <typename T> constexpr auto var<T> = T{}; +} // namespace GH144775 +#endif _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits