Skip to content

Fix cross-references in Clang attribute reference #142967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025

Conversation

aaronpuchert
Copy link
Member

Anchors are automatically generated, but adding another anchor with the same name hides the anchor that we actually want. Simply removing the unnecessary self-referential anchor lifetimebound fixes the links.

The documentation for coro_disable_lifetimebound and coro_lifetimebound also had an unnecessary redirection. It's possible to change the link text to differ from the heading, but I think that's not necessary here.

Also fix a reference in clang-tidy that was using the (unstable) numbered anchor.

Anchors are automatically generated, but adding another anchor with the
same name hides the anchor that we actually want. Simply removing the
unnecessary self-referential anchor `lifetimebound` fixes the links.

The documentation for coro_disable_lifetimebound and coro_lifetimebound
also had an unnecessary redirection. It's possible to change the link
text to differ from the heading, but I think that's not necessary here.

Also fix a reference in clang-tidy that was using the (unstable)
numbered anchor.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang-tools-extra clang-tidy clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2025

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-tools-extra

@llvm/pr-subscribers-clang-tidy

Author: Aaron Puchert (aaronpuchert)

Changes

Anchors are automatically generated, but adding another anchor with the same name hides the anchor that we actually want. Simply removing the unnecessary self-referential anchor lifetimebound fixes the links.

The documentation for coro_disable_lifetimebound and coro_lifetimebound also had an unnecessary redirection. It's possible to change the link text to differ from the heading, but I think that's not necessary here.

Also fix a reference in clang-tidy that was using the (unstable) numbered anchor.


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

2 Files Affected:

  • (modified) clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst (+1-1)
  • (modified) clang/include/clang/Basic/AttrDocs.td (+2-7)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
index ba47399914de3..325a0a2aa9cc2 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
@@ -42,7 +42,7 @@ on the control flow of the function, an overload where all problematic
 
 This issue can also be resolved by adding ``[[clang::lifetimebound]]``. Clang
 enable ``-Wdangling`` warning by default which can detect mis-uses of the
-annotated function. See `lifetimebound attribute <https://clang.llvm.org/docs/AttributeReference.html#id11>`_
+annotated function. See `lifetimebound attribute <https://clang.llvm.org/docs/AttributeReference.html#lifetimebound>`_
 for details.
 
 .. code-block:: c++
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 40b9f8142bb69..1e7ffec592034 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4392,8 +4392,6 @@ annotated parameter.
       addToSet(str, s); // Not detected.
     }
   }
-
-.. _`lifetimebound`: https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
   }];
 }
 
@@ -9038,14 +9036,14 @@ def CoroLifetimeBoundDoc : Documentation {
   let Category = DocCatDecl;
   let Content = [{
 The ``[[clang::coro_lifetimebound]]`` is a class attribute which can be applied
-to a coroutine return type (`CRT`_) (i.e.
+to a coroutine return type (`coro_return_type, coro_wrapper`_) (i.e.
 it should also be annotated with ``[[clang::coro_return_type]]``).
 
 All parameters of a function are considered to be lifetime bound if the function returns a
 coroutine return type (CRT) annotated with ``[[clang::coro_lifetimebound]]``.
 This lifetime bound analysis can be disabled for a coroutine wrapper or a coroutine by annotating the function
 with ``[[clang::coro_disable_lifetimebound]]`` function attribute .
-See `documentation`_ of ``[[clang::lifetimebound]]`` for details about lifetime bound analysis.
+See documentation of `lifetimebound`_ for details about lifetime bound analysis.
 
 
 Reference parameters of a coroutine are susceptible to capturing references to temporaries or local variables.
@@ -9105,9 +9103,6 @@ but do not pass them to the underlying coroutine or pass them by value.
   void use() {
     auto task = coro_wrapper(1); // use of temporary is fine as the argument is not lifetime bound.
   }
-
-.. _`documentation`: https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
-.. _`CRT`: https://clang.llvm.org/docs/AttributeReference.html#coro-return-type
 }];
 }
 

Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea about documentation formats ;) @AaronBallman might know better than I, but nothing that LOOKS wrong here.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This all looks correct to me, so LG assume precommit CI doesn't find issues with the Sphinx markdown.

@aaronpuchert
Copy link
Member Author

Yes, it doesn't seem to build the docs. The Windows failure looks unrelated:

llvm-lit.py: C:\_work\llvm-project\llvm-project\llvm\utils\lit\lit\llvm\config.py:312: fatal: Couldn't find the include dir for Clang ('c:\_work\llvm-project\llvm-project\build\bin\clang.exe')

@aaronpuchert aaronpuchert merged commit 8641a2c into llvm:main Jun 5, 2025
16 of 17 checks passed
@aaronpuchert aaronpuchert deleted the fix-attribute-ref-links branch June 5, 2025 16:30
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
Anchors are automatically generated, but adding another anchor with the
same name hides the anchor that we actually want. Simply removing the
unnecessary self-referential anchor `lifetimebound` fixes the links.

The documentation for coro_disable_lifetimebound and coro_lifetimebound
also had an unnecessary redirection. It's possible to change the link
text to differ from the heading, but I think that's not necessary here.

Also fix a reference in clang-tidy that was using the (unstable)
numbered anchor.
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
Anchors are automatically generated, but adding another anchor with the
same name hides the anchor that we actually want. Simply removing the
unnecessary self-referential anchor `lifetimebound` fixes the links.

The documentation for coro_disable_lifetimebound and coro_lifetimebound
also had an unnecessary redirection. It's possible to change the link
text to differ from the heading, but I think that's not necessary here.

Also fix a reference in clang-tidy that was using the (unstable)
numbered anchor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category clang-tidy clang-tools-extra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants