[PATCH] D76197: clang-format: Use block indentation for braced initializations

Daan De Meyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 15 11:15:05 PDT 2020


DaanDeMeyer updated this revision to Diff 250429.
DaanDeMeyer added a comment.

New implementation that breaks fewer tests.

It seems to be expected that block kind is `BK_Unknown` for C struct braced init lists. Is that supposed to be the case?

There's still quite some tests failures but most of them are simply indentation changes from 4 to 2 spaces (which is LLVM's indentation size) which might be unavoidable if we want this change to happen.


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

https://reviews.llvm.org/D76197

Files:
  clang/lib/Format/FormatToken.h


Index: clang/lib/Format/FormatToken.h
===================================================================
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -508,7 +508,7 @@
       return true;
     return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) ||
            (is(tok::l_brace) &&
-            (BlockKind == BK_Block || is(TT_DictLiteral) ||
+            (BlockKind == BK_Block || BlockKind == BK_Unknown || is(TT_DictLiteral) ||
              (!Style.Cpp11BracedListStyle && NestingLevel == 0))) ||
            (is(tok::less) && (Style.Language == FormatStyle::LK_Proto ||
                               Style.Language == FormatStyle::LK_TextProto));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76197.250429.patch
Type: text/x-patch
Size: 698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200315/a9261f54/attachment.bin>


More information about the cfe-commits mailing list