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

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 14 06:42:00 PST 2021


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:
> MyDeveloperDay wrote:
> > 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.
> Yeah, but I like my variant better. :)
but I'm not clever enough to understand it!


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

https://reviews.llvm.org/D95168



More information about the cfe-commits mailing list