[PATCH] D129443: [clang-format] Add option for aligning requires clause body

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 14 13:43:45 PDT 2022


HazardyKnusperkeks added a comment.

Looks very promising.



================
Comment at: clang/include/clang/Format/Format.h:396
+  /// \version 15
+  RequiresExpressionIndentationKind RequiresExpressionIndentation;
+
----------------
Please resort.


================
Comment at: clang/include/clang/Format/Format.h:3885
            AlignOperands == R.AlignOperands &&
+           RequiresExpressionIndentation == R.RequiresExpressionIndentation &&
            AlignTrailingComments == R.AlignTrailingComments &&
----------------
Please resort.


================
Comment at: clang/unittests/Format/FormatTest.cpp:24805-24810
+  verifyFormat("template <typename T> void f() {\n"
+               "  if constexpr (requires(T t) {\n"
+               "                  { t.bar() } -> std::same_as<bool>;\n"
+               "                }) {\n"
+               "  }\n"
+               "}",
----------------
This is a bad example, since we can't see any difference.

What happens if it's not the first expression in the if.


================
Comment at: clang/unittests/Format/FormatTest.cpp:20036
   Style.Language = FormatStyle::LK_Cpp;
+  CHECK_PARSE_BOOL(AlignRequiresClauseBody);
   CHECK_PARSE_BOOL(AlignTrailingComments);
----------------
Please add the parsing test for the enum.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129443



More information about the cfe-commits mailing list