https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/203303
The new documentation mirrors the existing docs for annotate_type. >From 3492bf5ce199003ec7014e2fb965bd60c54de279 Mon Sep 17 00:00:00 2001 From: Aaron Ballman <[email protected]> Date: Thu, 11 Jun 2026 11:20:18 -0400 Subject: [PATCH] Document the [[clang::annotate]] attribute The new documentation mirrors the existing docs for annotate_type. --- clang/include/clang/Basic/Attr.td | 2 +- clang/include/clang/Basic/AttrDocs.td | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 7f7e9489782a7..d494a00daed38 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1039,7 +1039,7 @@ def Annotate : InheritableParamOrStmtAttr { }]; let PragmaAttributeSupport = 1; let AcceptsExprPack = 1; - let Documentation = [Undocumented]; + let Documentation = [AnnotateDocs]; } def AnnotateType : TypeAttr { diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index dab778d4047aa..28b1a2fe05989 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -9145,6 +9145,33 @@ point." }]; } +def AnnotateDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ +This attribute is used to add annotations to declarations or statements, +typically for use by static analysis tools that are not integrated into the +core Clang compiler (e.g., Clang-Tidy checks or out-of-tree Clang-based tools). +It is a counterpart to the `annotate_type` attribute, which serves the same +purpose, but for types. + +The attribute takes a mandatory string literal argument specifying the +annotation category and an arbitrary number of optional arguments that provide +additional information specific to the annotation category. The optional +arguments must be constant expressions of arbitrary type. + +For example: + +.. code-block:: c++ + + [[clang::annotate("category1", "foo", 1)]] void func(int val [[clang::annotate("category2")]]) { + [[clang::annotate("category3")]] if (val) { + + } + } + + }]; +} + def AnnotateTypeDocs : Documentation { let Category = DocCatType; let Heading = "annotate_type"; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
