<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Support for branch attribute macros"
href="https://bugs.llvm.org/show_bug.cgi?id=49840">49840</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Support for branch attribute macros
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>N.James93@hotmail.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>