-
Notifications
You must be signed in to change notification settings - Fork 15k
Closed
Labels
clang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature
Description
The RemoveBracesLLVM
option doesn't remove the braces of an else
block that contains a single if
statement when the body of the if
statement is a block:
$ cat test.cpp
void f() {
if (a1)
f1();
else {
if (a2)
f2();
}
if (a3)
f3();
else {
if (b) {
g();
h();
}
}
}
$ clang-format -version
clang-format version 15.0.0 (https://github.com/llvm/llvm-project 09865ae95dbf0322bbf3e7b3847b2b11373a0297)
$ clang-format -style="{InsertBraces: true, RemoveBracesLLVM: true}" test.cpp
void f() {
if (a1)
f1();
else if (a2)
f2();
if (a3) {
f3();
} else {
if (b) {
g();
h();
}
}
}
Expected output:
...
if (a3) {
f3();
} else if (b) {
g();
h();
}
...
Metadata
Metadata
Assignees
Labels
clang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature