<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 - Space added after 'return' when used as argument to macro"
href="https://bugs.llvm.org/show_bug.cgi?id=33989">33989</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Space added after 'return' when used as argument to macro
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</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>christian.ridderstrom@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Our code base contains e.g. a line like this
LASSERT(sugs != 0, return);
where 'LASSERT' is a macro and the argument 'return'
specifies how to abort if the condition is met.
Applying clang-format to this line adds a space after 'return',
resulting in this line:
LASSERT(sugs != 0, return );
The addition of the space is a minor inconvenience, albeit irritating.
Is clang-format behaving correctly here?
Below is test code demonstrating the example.
/*
Using clang-format on this source
adds a space after the 'return' in
the macro's last argument.
Same result for multiple versions,
e.g. ver 3.8, 3.9, 4.0 and 5.0.
*/
// Custom assert macro where 'return'
// might make sense as argument.
#define LASSERT(expr, escape)
\
if (expr) {
\
} else {
\
escape;
\
}
void f(int x) {
LASSERT(x != 5, return);
// clang-format produces:
// LASSERT(x != 5, return);
LASSERT(x != 6, {});
}
int main() {
f(5);
return 0;
}
/*
Issue can be triggered by using e.g.
-style LLVM
*/</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>