This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. aaronpuchert marked an inline comment as done. Closed by commit rG63ef0e17e288: Comment AST: Add support for variable templates (authored by aaronpuchert).
Changed prior to commit: https://reviews.llvm.org/D111266?vs=377663&id=385955#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111266/new/ https://reviews.llvm.org/D111266 Files: clang/include/clang/AST/Comment.h clang/lib/AST/Comment.cpp clang/test/Sema/warn-documentation.cpp
Index: clang/test/Sema/warn-documentation.cpp =================================================================== --- clang/test/Sema/warn-documentation.cpp +++ clang/test/Sema/warn-documentation.cpp @@ -1323,6 +1323,17 @@ */ int (*functionPointerVariable)(int i); +#if __cplusplus >= 201402L +/** + * functionPointerVariableTemplate + * + * @param i is something. + * @returns integer. + */ +template<typename T> +int (*functionPointerVariableTemplate)(T i); +#endif + struct HasFields { /** * functionPointerField @@ -1331,6 +1342,18 @@ * @returns integer. */ int (*functionPointerField)(int i); + +#if __cplusplus >= 201402L + /** + * functionPointerTemplateMember + * + * @tparam T some type. + * @param i is integer. + * @returns integer. + */ + template<typename T> + static int (*functionPointerTemplateMember)(int i); +#endif }; // expected-warning@+5 {{parameter 'p' not found in the function declaration}} @@ -1343,6 +1366,23 @@ */ void (*functionPointerVariableThatLeadsNowhere)(); +#if __cplusplus >= 201402L +// expected-warning@+8 {{template parameter 'X' not found in the template declaration}} +// expected-note@+7 {{did you mean 'T'?}} +// expected-warning@+7 {{parameter 'p' not found in the function declaration}} +// expected-note@+6 {{did you mean 'x'?}} +// expected-warning@+6 {{'\returns' command used in a comment that is attached to a function returning void}} +/** + * functionPointerVariable + * + * \tparam X typo + * \param p not here. + * \returns integer. + */ +template<typename T> +void (*functionPointerVariableTemplateThatLeadsNowhere)(T x); +#endif + // Still warn about param/returns commands for variables that don't specify // the type directly: Index: clang/lib/AST/Comment.cpp =================================================================== --- clang/lib/AST/Comment.cpp +++ clang/lib/AST/Comment.cpp @@ -294,6 +294,12 @@ Kind = ClassKind; break; case Decl::Var: + if (const VarTemplateDecl *VTD = + cast<VarDecl>(CommentDecl)->getDescribedVarTemplate()) { + TemplateKind = TemplateSpecialization; + TemplateParameters = VTD->getTemplateParameters(); + } + LLVM_FALLTHROUGH; case Decl::Field: case Decl::EnumConstant: case Decl::ObjCIvar: @@ -305,6 +311,15 @@ TSI = PD->getTypeSourceInfo(); Kind = VariableKind; break; + case Decl::VarTemplate: { + const VarTemplateDecl *VTD = cast<VarTemplateDecl>(CommentDecl); + Kind = VariableKind; + TemplateKind = Template; + TemplateParameters = VTD->getTemplateParameters(); + if (const VarDecl *VD = VTD->getTemplatedDecl()) + TSI = VD->getTypeSourceInfo(); + break; + } case Decl::Namespace: Kind = NamespaceKind; break; Index: clang/include/clang/AST/Comment.h =================================================================== --- clang/include/clang/AST/Comment.h +++ clang/include/clang/AST/Comment.h @@ -1031,8 +1031,8 @@ ClassKind, /// Something that we consider a "variable": - /// \li namespace scope variables; - /// \li static and non-static class data members; + /// \li namespace scope variables and variable templates; + /// \li static and non-static class data members and member templates; /// \li enumerators. VariableKind,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits