[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 22 06:28:08 PST 2022


curdeius added inline comments.


================
Comment at: clang/docs/ClangFormatStyleOptions.rst:406
+
+  Options for aligning stuff.
 
----------------
Stuff?


================
Comment at: clang/docs/ClangFormatStyleOptions.rst:482-483
+
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
+    assignments like ``+=``'s are aligned along with ``=``'s.
+
----------------



================
Comment at: clang/docs/ClangFormatStyleOptions.rst:510-512
+      regardless of this option:
+      a     = 2;
+      bbb >>= 2;
----------------
IMO, it would be easier to understand if you appended (after a blank line) the "regardless" example into both true and false part.


================
Comment at: clang/docs/ClangFormatStyleOptions.rst:529
+
+  Options for aligning stuff.
+
----------------
Ditto.


================
Comment at: clang/docs/ClangFormatStyleOptions.rst:1408-1415
+  Precise control over the wrapping of braces.
+
+  .. code-block:: c++
+
+    # Should be declared this way:
+    BreakBeforeBraces: Custom
+    BraceWrapping:
----------------
That's an unrelated change. Could you please do it in another (NFC) revision?


================
Comment at: clang/docs/ClangFormatStyleOptions.rst:4163-4171
+  Precise control over the spacing before parentheses.
+
+  .. code-block:: c++
+
+    # Should be declared this way:
+    SpaceBeforeParens: Custom
+    SpaceBeforeParensOptions:
----------------
Ditto.


================
Comment at: llvm/docs/YamlIO.rst:561-590
+.. code-block:: c++
+
+    template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
+      static void enumInput(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) {
+        IO.enumCase(Value, "None", FormatStyle::AlignConsecutiveStyle({}));
+        IO.enumCase(Value, "Consecutive",
+                    FormatStyle::AlignConsecutiveStyle({/*.Enabled=*/true}));
----------------
A simpler example (not clang-format specific) would be better.


================
Comment at: llvm/include/llvm/Support/YAMLTraits.h:66
   // static std::string validate(IO &io, T &fields);
+  // static void enumInput(IO &io, T &value);
   //
----------------
Can't it be `enumeration` to match `ScalarEnumerationTraits`? Or would it clash?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599



More information about the cfe-commits mailing list