[PATCH] D95168: [clang-format] Add Insert/Remove Braces option

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 13 05:56:54 PST 2021


MyDeveloperDay marked 8 inline comments as done.
MyDeveloperDay added inline comments.


================
Comment at: clang/lib/Format/BraceInserter.cpp:21-56
+bool SupportsAnyAutomaticBraces(FormatStyle &Style, bool insertion) {
+  if (insertion) {
+    if (Style.AutomaticBraces.AfterIf == FormatStyle::BIS_Always)
+      return true;
+    if (Style.AutomaticBraces.AfterIf == FormatStyle::BIS_WrapLikely)
+      return true;
+    if (Style.AutomaticBraces.AfterFor == FormatStyle::BIS_Always)
----------------
HazardyKnusperkeks wrote:
> How about something like that?
I think for now

```
bool SupportsAnyAutomaticBraces(FormatStyle &Style, bool insertion) {
  if (   Style.AutomaticBraces.AfterIf == FormatStyle::BIS_Leave
      && Style.AutomaticBraces.AfterFor == FormatStyle::BIS_Leave
      && Style.AutomaticBraces.AfterWhile == FormatStyle::BIS_Leave
      && Style.AutomaticBraces.AfterDo == FormatStyle::BIS_Leave
      && Style.AutomaticBraces.AfterElse == FormatStyle::BIS_Leave)
      return false;

  if (!insertion){
    if (Style.AutomaticBraces.AfterIf != FormatStyle::BIS_Remove)
    && Style.AutomaticBraces.AfterFor != FormatStyle::BIS_Remove)
    && Style.AutomaticBraces.AfterWhile != FormatStyle::BIS_Remove)
    && Style.AutomaticBraces.AfterDo != FormatStyle::BIS_Remove)
    && Style.AutomaticBraces.AfterElse != FormatStyle::BIS_Remove)
      return false;
  }
  return true;
}
```

Should cover it.


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

https://reviews.llvm.org/D95168



More information about the cfe-commits mailing list