gedare updated this revision to Diff 537531.
gedare added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25535,26 +25535,26 @@
                "    .foo = \"xxxxxxxxxxxxx\",\n"
                "    .bar = \"yyyyyyyyyyyyy\",\n"
                "    .baz = \"zzzzzzzzzzzzz\"\n"
-               "};\n",
+               "};",
                Style);
   // List initialization.
   verifyFormat("SomeStruct s{\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "};\n",
+               "};",
                Style);
   verifyFormat("SomeStruct{\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "};\n",
+               "};",
                Style);
   verifyFormat("new SomeStruct{\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "};\n",
+               "};",
                Style);
   // Member initializer.
   verifyFormat("class SomeClass {\n"
@@ -25563,62 +25563,62 @@
                "      \"yyyyyyyyyyyyy\",\n"
                "      \"zzzzzzzzzzzzz\",\n"
                "  };\n"
-               "};\n",
+               "};",
                Style);
   // Constructor member initializer.
   verifyFormat("SomeClass::SomeClass : strct{\n"
                "                           \"xxxxxxxxxxxxx\",\n"
                "                           \"yyyyyyyyyyyyy\",\n"
                "                           \"zzzzzzzzzzzzz\",\n"
-               "                       } {}\n",
+               "                       } {}",
                Style);
   // Copy initialization.
   verifyFormat("SomeStruct s = SomeStruct{\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "};\n",
+               "};",
                Style);
   // Copy list initialization.
   verifyFormat("SomeStruct s = {\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "};\n",
+               "};",
                Style);
   // Assignment operand initialization.
   verifyFormat("s = {\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "};\n",
+               "};",
                Style);
   // Returned object initialization.
   verifyFormat("return {\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "};\n",
+               "};",
                Style);
   // Initializer list.
   verifyFormat("auto initializerList = {\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "};\n",
+               "};",
                Style);
   // Function parameter initialization.
   verifyFormat("func({\n"
                "    \"xxxxxxxxxxxxx\",\n"
                "    \"yyyyyyyyyyyyy\",\n"
                "    \"zzzzzzzzzzzzz\",\n"
-               "});\n",
+               "});",
                Style);
   // Nested init lists.
   verifyFormat("SomeStruct s = {\n"
                "    {{init1, init2, init3, init4, init5},\n"
                "     {init1, init2, init3, init4, init5}}\n"
-               "};\n",
+               "};",
                Style);
   verifyFormat("SomeStruct s = {\n"
                "    {{\n"
@@ -25629,7 +25629,7 @@
                "         .init5 = 5,\n"
                "     },\n"
                "     {init1, init2, init3, init4, init5}}\n"
-               "};\n",
+               "};",
                Style);
   verifyFormat("SomeArrayT a[3] = {\n"
                "    {\n"
@@ -25641,7 +25641,7 @@
                "        bar,\n"
                "    },\n"
                "    SomeArrayT{},\n"
-               "};\n",
+               "};",
                Style);
   verifyFormat("SomeArrayT a[3] = {\n"
                "    {foo},\n"
@@ -25658,7 +25658,7 @@
                "        },\n"
                "    },\n"
                "    {baz},\n"
-               "};\n",
+               "};",
                Style);
 }
 
Index: clang/lib/Format/FormatToken.cpp
===================================================================
--- clang/lib/Format/FormatToken.cpp
+++ clang/lib/Format/FormatToken.cpp
@@ -76,14 +76,13 @@
 }
 
 bool FormatToken::isBlockIndentedInitRBrace(const FormatStyle &Style) const {
-  if (isNot(tok::r_brace))
-    return false;
-  if (Style.Cpp11BracedListStyle != true ||
+  assert(is(tok::r_brace));
+  if (!Style.Cpp11BracedListStyle ||
       Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent) {
     return false;
   }
-  auto LBrace = MatchingParen;
-  assert(LBrace);
+  const auto *LBrace = MatchingParen;
+  assert(LBrace && LBrace->is(tok::l_brace));
   if (LBrace->is(BK_BracedInit))
     return true;
   if (LBrace->Previous && LBrace->Previous->is(tok::equal))
Index: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -363,7 +363,8 @@
   }
   if (CurrentState.BreakBeforeClosingBrace &&
       (Current.closesBlockOrBlockTypeList(Style) ||
-       Current.isBlockIndentedInitRBrace(Style))) {
+       (Current.is(tok::r_brace) &&
+        Current.isBlockIndentedInitRBrace(Style)))) {
     return true;
   }
   if (CurrentState.BreakBeforeClosingParen && Current.is(tok::r_paren))
Index: clang/docs/ClangFormatStyleOptions.rst
===================================================================
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -238,10 +238,11 @@
           argument1, argument2
       )
 
-    \note
+
+    .. note::
+
      This currently only applies to braced initializer lists (when
      ``Cpp11BracedListStyle`` is ``true``) and parentheses.
-    \endnote
 
 
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to