[PATCH] clang-format: Add ability to align assignment operators

Marek Kurdej curdeius at gmail.com
Tue Apr 7 03:58:00 PDT 2015


================
Comment at: lib/Format/WhitespaceManager.cpp:98
@@ -97,2 +97,3 @@
   alignEscapedNewlines();
+  alignAssignmentOperators();
   generateChanges();
----------------
Shouldn't aligning of operators be done before the aligning of trailing comments?
Moreover, please add tests with aligned assignment operators and trailing comments as well as with operators and escaped newlines.

================
Comment at: unittests/Format/FormatTest.cpp:8402
@@ -8350,1 +8401,3 @@
+}
+
 TEST_F(FormatTest, LinuxBraceBreaking) {
----------------
Add tests like

```
EXPECT_EQ(
            "int oneTwoThree = 123; // comment\n"
            "int oneTwo      = 12;  // comment",
            format(
                   "int oneTwoThree = 123;// comment\n"
                   "int oneTwo = 12;// comment", Alignment));
```

and

```
EXPECT_EQ(
            "#define MACRO                 \\\n"
            "int oneTwoThree = 123;        \\\n"
            "int oneTwo      = 12;         \\\n",
            format(
                   "#define MACRO \\"
                   "int oneTwoThree = 123;\\\n"
                   "int oneTwo = 12;\\", Alignment));
```

http://reviews.llvm.org/D8821

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list