[PATCH] D93846: [clang-format] PR16518 Add flag to suppress empty line insertion before access modifier

Albertas Vyšniauskas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 28 10:14:47 PST 2020


thezbyg added inline comments.


================
Comment at: clang/unittests/Format/FormatTest.cpp:8544-8556
+  EXPECT_EQ("struct foo {\n"
+            "  int i;\n"
+            "\n"
+            "private:\n"
+            "  int j;\n"
+            "}\n",
+            format("struct foo {\n"
----------------
MyDeveloperDay wrote:
> if you use verifyFormat it will check what happens when it messes the code up to ensure its stable
After switching to verifyFormat all tests pass when checking C++ formatting, but some of the same tests fail in Objective-C++ check:
C style comment is attached to previous line:
```
      Expected: Expected.str()
      Which is: "struct foo {\n  /* comment */\nprivate:\n  int i;\n  int j;\n}\n"
To be equal to: format(test::messUp(Code), ObjCStyle)
      Which is: "struct foo { /* comment */\nprivate:\n  int i;\n  int j;\n}\n"
With diff:
@@ -1,4 +1,3 @@
-struct foo {
-  /* comment */
+struct foo { /* comment */
 private:
   int i;

```
Empty line before access modifier is removed:
```
      Expected: Expected.str()
      Which is: "struct foo {\n  int i;\n\nprivate:\n  int j;\n}\n"
To be equal to: format(test::messUp(Code), ObjCStyle)
      Which is: "struct foo {\n  int i;\nprivate:\n  int j;\n}\n"
With diff:
@@ -1,5 @@
 struct foo {
   int i;
-
 private:
   int j;
```
Looks like empty lines before modifiers are removed for Objective-C++ language. What should I do?


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

https://reviews.llvm.org/D93846



More information about the cfe-commits mailing list