[PATCH] D100727: [clang-format] Correctly apply AllowShortIfStatementsOnASingleLine: Always to else branch.
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 19 00:24:31 PDT 2021
HazardyKnusperkeks added a comment.
In D100727#2697490 <https://reviews.llvm.org/D100727#2697490>, @curdeius wrote:
> In D100727#2697419 <https://reviews.llvm.org/D100727#2697419>, @HazardyKnusperkeks wrote:
>
>> How is
>>
>> if (a) return;
>> else
>> return;
>>
>> formatted with the different options?
>
> Do you have something specific in mind?
This is the example for `WithoutElse` from the documentation, and I don't think it is covered with the tests.
>> And from the documentation I think it was intended that only `if` is short, never the `else`.
>
> There's already an option WithoutElse that should do exactly this.
Yeah, that one is either badly named, or the whole option is badly documented. :)
SIS_WithoutElse (in configuration: WithoutElse) Without else put short ifs on the same line only if the else is not a compound statement.
SIS_Always (in configuration: Always) Always put short ifs on the same line if the else is not a compound statement or not.
How I read the documentation the whole option is only about the `if`, the `else` is only checked if it is a compound statement or nor, it is not formatted.
As said I agree that one should also allow short `else`s.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100727/new/
https://reviews.llvm.org/D100727
More information about the cfe-commits
mailing list