[llvm-bugs] [Bug 49840] New: Support for branch attribute macros
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 5 02:08:18 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49840
Bug ID: 49840
Summary: Support for branch attribute macros
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: N.James93 at hotmail.co.uk
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
I'm not sure how this is best implemented but I couldn't find a nice way to
format code with the c++20 [[likely]] and [[unlikely]] branch attributes if
those attributes are in macro form.
Spelling the attributes normally results in code like this:
if (StartIndex == End) [[unlikely]]
return npos;
Or if the line needs to be wrapped:
if (StartIndex == End)
[[unlikely]]
return npos;
In both these cases its obvious the `return npos;` is the true branch of the if
statement. However when using a macro for these attributes this is no longer
apparent, instead it appears that `BRANCH_UNLIKELY` is the true branch, and
`return npos;` if a statement following the if.
if (StartIndex == End)
BRANCH_UNLIKELY
return npos;
I set AttributeMacros accordingly, but it seems clang-format doesn't pay
attention to that style setting for if/else branch attributes.
I haven't tested how this plays with switch cases which also support the same
annotations.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210405/00f2f820/attachment-0001.html>
More information about the llvm-bugs
mailing list