[llvm-bugs] [Bug 33989] New: Space added after 'return' when used as argument to macro
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jul 29 16:50:03 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33989
Bug ID: 33989
Summary: Space added after 'return' when used as argument to
macro
Product: clang
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: christian.ridderstrom at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
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
*/
--
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/20170729/8ee50a6f/attachment-0001.html>
More information about the llvm-bugs
mailing list