https://github.com/kovan created https://github.com/llvm/llvm-project/pull/186590
## Summary - The first code example in the "confusing standard behavior" section had a comment claiming `[[unlikely]]` makes the branch unlikely, contradicting a later example showing the same placement being ignored - Rewords the comment to clarify this is the C++ Standard's recommendation that Clang does not follow, since the attribute is not on the substatement - The code example is kept unchanged — the contradiction was in the comment, not the code Fixes #126362 Continues the work from #126372 (reviewer feedback from @Sirraide and @AaronBallman indicated the fix should reword the comment rather than move the attribute) >From 964fc11b37b8b9fb6ea696b0bcb86710c9a880f4 Mon Sep 17 00:00:00 2001 From: kovan <[email protected]> Date: Sat, 14 Mar 2026 13:07:03 +0100 Subject: [PATCH] [clang][docs] Clarify [[unlikely]] example in compound statement The comment on the first example in the "confusing" section claimed the branch is considered unlikely, but Clang actually ignores the attribute when it is not placed on the substatement of an if/else. This contradicted the later example showing the same placement being ignored. Reword the comment to clarify this is the standard's recommendation that Clang does not follow, consistent with the introductory text and the other examples in the section. Fixes #126362 Continues the work from PR #126372 --- clang/include/clang/Basic/AttrDocs.td | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 718df8c7154a2..0c5a15e610114 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -2686,8 +2686,10 @@ 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. + [[unlikely]] --b; // Per the standard this is in the path of + // execution, so this branch should be considered + // unlikely. However, Clang ignores the attribute + // here since it is not on the substatement. } if (b) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
