Skip to content
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

[clang][docs] Fix example in likely/unlikely attr documentation #126372

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcauberer
Copy link
Member

Fixes #126362

@marcauberer marcauberer requested a review from mordante February 8, 2025 15:05
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 8, 2025

@llvm/pr-subscribers-clang

Author: Marc Auberer (marcauberer)

Changes

Fixes #126362


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

1 Files Affected:

  • (modified) clang/include/clang/Basic/AttrDocs.td (+3-3)
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 0ad4c958d09830..2a0354a3222eba 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2450,9 +2450,9 @@ path of execution, but that can be confusing:
 
 .. code-block:: c++
 
-  if (b) {
-    [[unlikely]] --b; // In the path of execution,
-                      // this branch is considered unlikely.
+  if (b) [[unlikely]] {
+    --b; // In the path of execution,
+         // this branch is considered unlikely.
   }
 
   if (b) {

Copy link
Member

@Sirraide Sirraide left a comment

Choose a reason for hiding this comment

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

Hmm, I think what this section is trying to demonstrate is that ‘According to the standard, this is in the path of execution and therefore supposed to be considered unlikely, but we don’t do that’, so maybe it’d be better to reword/expand the comment instead?

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 documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contradictory documentation for [[unlikely]]
3 participants