[cfe-dev] Avoid bin packing conditions inside if statement
Mikhail Artemyev via cfe-dev
cfe-dev at lists.llvm.org
Fri Aug 11 08:19:24 PDT 2017
Hi All,
I'm curious if anybody tried to implement an option for clang-format to
prevent bin packing conditions inside if statements (or maybe it already
exists and I missed it).
Here is an example,
% cat test.cpp
void func(int a,
double b,
bool c);
int main() {
func(123456,
1.23456,
false);
if(false ||
true ||
false) {
// stuff
}
return 0;
}
Formatting with default settings (except a column limit) produces the
following:
% ./clang-format -style="{BasedOnStyle: LLVM, ColumnLimit: 27}" test.cpp
void func(int a, double b,
bool c);
int main() {
func(123456, 1.23456,
false);
if (false || true ||
false) {
// stuff
}
return 0;
}
It's possible to prevent bin packing of function parameters and arguments:
% ./clang-format -style="{BasedOnStyle: LLVM, ColumnLimit: 27,
BinPackParameters: false, BinPackArguments: false}" test.cpp
void func(int a,
double b,
bool c);
int main() {
func(123456,
1.23456,
false);
if (false || true ||
false) {
// stuff
}
return 0;
}
But nothing I can do about conditions inside the if statement. And I
believe such an option would be quite useful as it provides the same
readability benefits as BinPackParameters and BinPackArguments.
Thanks,
Mikhail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170811/9290d236/attachment.html>
More information about the cfe-dev
mailing list