<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 - Follow up on bug 46969: clang-format splits bitshift operator >> into > >"
href="https://bugs.llvm.org/show_bug.cgi?id=49868">49868</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Follow up on bug 46969: clang-format splits bitshift operator >> into > >
</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>ezra@ezisland.org
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-format splits >> (bitshift) into > > (and thus breaks code)"
href="show_bug.cgi?id=46969">Bug 46969</a> (<a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-format splits >> (bitshift) into > > (and thus breaks code)"
href="show_bug.cgi?id=46969">https://bugs.llvm.org/show_bug.cgi?id=46969</a>) describes how
clang-format (version <= 11) can occasionally split a right-bitshift operator
(>>) into two angle-brackets by inserting a space in between (> >).
A patch for this issue has been submitted for release 12.x as per
<a href="https://reviews.llvm.org/D86581">https://reviews.llvm.org/D86581</a>
The review comments acknowledge that some situations in which the bitshift
operator is split are not correctly resolved by the patch (due in part to the
ambiguity introduced by c++14 variable templates).
Since this issue is present in release 12.x and possibly in trunk, I am raising
it as a follow up bug report for 46969.
Consider this simple example which is incorrectly transformed by clang-format
even in release 12.x:
Original:
int main() {
int x = 0;
int y = 0;
return x < y - 1 >> 1;
}
After clang-format:
int main() {
int x = 0;
int y = 0;
return x < y - 1 > > 1; /*<< Code is broken*/
}
I was wondering if there are any mitigation strategies for this issue. This has
cropped up as a problem for developers of source-to-source compilers which emit
c and c++ code that subsequently needs to be formatted. The emitted code might
contain such ambiguous syntax and we would like clang-format to take a more
conservative approach to formatting if possible in order to avoid modifying the
original behavior of the program.</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>