llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Oliver Hunt (ojhunt) <details> <summary>Changes</summary> The existing mechanism being used is to manually add a reference in the documentation. These references link to the beginning of the text rather than the heading for the attribute which is what this PR allows. --- Full diff: https://github.com/llvm/llvm-project/pull/118428.diff 3 Files Affected: - (modified) clang/include/clang/Basic/Attr.td (+3) - (modified) clang/include/clang/Basic/AttrDocs.td (+4-8) - (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+2) ``````````diff diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 618252f3e75247..522821a79063ac 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -55,6 +55,9 @@ class Documentation { // When set, specifies that the attribute is deprecated and can optionally // specify a replacement attribute. DocDeprecated Deprecated; + + // When set, specifies a label that can be used to reference the documentation + string Label = ""; } // Specifies that the attribute is explicitly omitted from the documentation, diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 5de39be4805600..7a82b8fa320590 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -3360,9 +3360,8 @@ def NoSanitizeAddressDocs : Documentation { // This function has multiple distinct spellings, and so it requires a custom // heading to be specified. The most common spelling is sufficient. let Heading = "no_sanitize_address, no_address_safety_analysis"; + let Label = "langext-address_sanitizer"; let Content = [{ -.. _langext-address_sanitizer: - Use ``__attribute__((no_sanitize_address))`` on a function or a global variable declaration to specify that address safety instrumentation (e.g. AddressSanitizer) should not be applied. @@ -3372,9 +3371,8 @@ variable declaration to specify that address safety instrumentation def NoSanitizeThreadDocs : Documentation { let Category = DocCatFunction; let Heading = "no_sanitize_thread"; + let Label = "langext-thread_sanitizer"; let Content = [{ -.. _langext-thread_sanitizer: - Use ``__attribute__((no_sanitize_thread))`` on a function declaration to specify that checks for data races on plain (non-atomic) memory accesses should not be inserted by ThreadSanitizer. The function is still instrumented by the @@ -3385,9 +3383,8 @@ tool to avoid false positives and provide meaningful stack traces. def NoSanitizeMemoryDocs : Documentation { let Category = DocCatFunction; let Heading = "no_sanitize_memory"; + let Label = "langext-memory_sanitizer"; let Content = [{ -.. _langext-memory_sanitizer: - Use ``__attribute__((no_sanitize_memory))`` on a function declaration to specify that checks for uninitialized memory should not be inserted (e.g. by MemorySanitizer). The function may still be instrumented by the tool @@ -3398,9 +3395,8 @@ to avoid false positives in other places. def CFICanonicalJumpTableDocs : Documentation { let Category = DocCatFunction; let Heading = "cfi_canonical_jump_table"; + let Label = "langext-cfi_canonical_jump_table"; let Content = [{ -.. _langext-cfi_canonical_jump_table: - Use ``__attribute__((cfi_canonical_jump_table))`` on a function declaration to make the function's CFI jump table canonical. See :ref:`the CFI documentation <cfi-canonical-jump-tables>` for more details. diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index 534bf2d01d7957..a66868ba2cc044 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -5178,6 +5178,8 @@ GetAttributeHeadingAndSpellings(const Record &Documentation, static void WriteDocumentation(const RecordKeeper &Records, const DocumentationData &Doc, raw_ostream &OS) { + if (const StringRef label = Doc.Documentation->getValueAsString("Label"); !label.empty()) + OS << ".. _" << label << ":\n\n"; OS << Doc.Heading << "\n" << std::string(Doc.Heading.length(), '-') << "\n"; // List what spelling syntaxes the attribute supports. `````````` </details> https://github.com/llvm/llvm-project/pull/118428 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits