[PATCH] D95168: [clang-format] Add InsertBraces option

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 1 16:47:23 PDT 2021


owenpan added a comment.

In D95168#3100376 <https://reviews.llvm.org/D95168#3100376>, @HazardyKnusperkeks wrote:

> In D95168#3099920 <https://reviews.llvm.org/D95168#3099920>, @owenpan wrote:
>
>> In D95168#3099739 <https://reviews.llvm.org/D95168#3099739>, @MyDeveloperDay wrote:
>>
>>> - Look further into possible Removal (I have an idea for how this might be possible, and super useful for LLVM where we don't like single if {} ), I'd like to round out on this before introducing the options rather than having to change them later
>>>
>>> - Should we add the possibility of removal should we change the option name to "AutomaticBraces" (thoughts?)
>>
>> As mentioned in D95168#3039033 <https://reviews.llvm.org/D95168#3039033>, I think it would be better to handle the removal separately. The LLVM Coding Standards has an entire section <https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements> about this. Some of the listed exceptions/examples there can make things more difficult.
>
> Difficult, yes. But I think it should be in one option.
> It hasn't to be implemented everything right from the start. And we could give all those cases a name and a different setting, so that the entire document would be mappable to a `.clang-format` with a convenience setting for all options at once.

What I meant to say is that we should have a separate patch for the removal implementation. I was not opposed to putting both insertion and removal under an `enum` option like "AutoBraces: Never, Insert, Remove, LLVM, ..."


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95168/new/

https://reviews.llvm.org/D95168



More information about the cfe-commits mailing list