[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 22 21:16:16 PST 2023


================
@@ -26451,6 +26451,20 @@ TEST_F(FormatTest, BreakAfterAttributes) {
                "{\n"
                "}",
                CtorDtorCode, Style);
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Attach;
+  Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;
+  verifyFormat("struct Foo {\n"
+               "  [[maybe_unused]]\n"
+               "  void operator+();\n"
+               "};\n"
+               "[[nodiscard]]\n"
+               "Foo& operator-(Foo&);",
+               "struct Foo {\n"
+               "[[maybe_unused]] void operator+();\n"
+               "};\n"
+               "[[nodiscard]] Foo &operator-(Foo&);",
----------------
owenca wrote:

Please split the test cases and use the single argument version of `verifyFormat`, e.g.:
```suggestion
  verifyFormat("struct Foo {\n"
               "  [[maybe_unused]]\n"
               "  void operator+();\n"
               "};\n"
               "[[nodiscard]]\n"
               "Foo &operator-(Foo &);",
               Style);

  Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;
  verifyFormat("[[nodiscard]]\n"
               "Foo& operator-(Foo&);",
```

https://github.com/llvm/llvm-project/pull/74943


More information about the cfe-commits mailing list