[clang] 88934a8 - [clang-format][NFC] Remove extraneous newlines in some unit test files

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 26 21:43:35 PDT 2023


Author: Owen Pan
Date: 2023-10-26T21:43:27-07:00
New Revision: 88934a82dced0116227e4ad9af8896d8fa0943b8

URL: https://github.com/llvm/llvm-project/commit/88934a82dced0116227e4ad9af8896d8fa0943b8
DIFF: https://github.com/llvm/llvm-project/commit/88934a82dced0116227e4ad9af8896d8fa0943b8.diff

LOG: [clang-format][NFC] Remove extraneous newlines in some unit test files

Added: 
    

Modified: 
    clang/unittests/Format/ConfigParseTest.cpp
    clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
    clang/unittests/Format/FormatTestCSharp.cpp
    clang/unittests/Format/FormatTestComments.cpp
    clang/unittests/Format/FormatTestJava.cpp
    clang/unittests/Format/FormatTestMacroExpansion.cpp
    clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index f90ed178d99c286..3a6667dbe0eb15d 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -849,7 +849,7 @@ TEST(ConfigParseTest, ParsesConfiguration) {
               "    Priority: 2\n"
               "  - Regex: .*\n"
               "    Priority: 1\n"
-              "    CaseSensitive: true\n",
+              "    CaseSensitive: true",
               IncludeStyle.IncludeCategories, ExpectedCategories);
   CHECK_PARSE("IncludeIsMainRegex: 'abc$'", IncludeStyle.IncludeIsMainRegex,
               "abc$");

diff  --git a/clang/unittests/Format/DefinitionBlockSeparatorTest.cpp b/clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
index 5cf4edcbdf2e5ab..f5489498a93b9e8 100644
--- a/clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
+++ b/clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
@@ -140,7 +140,7 @@ TEST_F(DefinitionBlockSeparatorTest, Basic) {
 
   verifyFormat("enum Foo { FOO, BAR };\n"
                "\n"
-               "enum Bar { FOOBAR, BARFOO };\n",
+               "enum Bar { FOOBAR, BARFOO };",
                Style);
 
   FormatStyle BreakAfterReturnTypeStyle = Style;
@@ -158,7 +158,7 @@ TEST_F(DefinitionBlockSeparatorTest, Basic) {
                "    int r = t * p;\n"
                "    return r;\n"
                "  }\n"
-               "}\n",
+               "}",
                BreakAfterReturnTypeStyle);
 }
 

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp
index 05d20c5ef19225d..4a0840d32341e84 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -530,19 +530,19 @@ TEST_F(FormatTestCSharp, AttributesIndentation) {
   verifyFormat("[SuppressMessage(\"A\", \"B\", Justification = \"C\")]\n"
                "public override X Y()\n"
                "{\n"
-               "}\n",
+               "}",
                Style);
 
   verifyFormat("[SuppressMessage]\n"
                "public X Y()\n"
                "{\n"
-               "}\n",
+               "}",
                Style);
 
   verifyFormat("[SuppressMessage]\n"
                "public override X Y()\n"
                "{\n"
-               "}\n",
+               "}",
                Style);
 
   verifyFormat("public A(B b) : base(b)\n"
@@ -551,7 +551,7 @@ TEST_F(FormatTestCSharp, AttributesIndentation) {
                "    public override X Y()\n"
                "    {\n"
                "    }\n"
-               "}\n",
+               "}",
                Style);
 
   verifyFormat("public A : Base\n"
@@ -560,7 +560,7 @@ TEST_F(FormatTestCSharp, AttributesIndentation) {
                "[Test]\n"
                "public Foo()\n"
                "{\n"
-               "}\n",
+               "}",
                Style);
 
   verifyFormat("namespace\n"
@@ -572,7 +572,7 @@ TEST_F(FormatTestCSharp, AttributesIndentation) {
                "public Foo()\n"
                "{\n"
                "}\n"
-               "}\n",
+               "}",
                Style);
 }
 
@@ -1561,7 +1561,7 @@ TEST_F(FormatTestCSharp, NamespaceIndentation) {
                "public interface Name1\n"
                "{\n"
                "}\n"
-               "}\n",
+               "}",
                Style);
 
   verifyFormat("namespace A.B\n"
@@ -1569,7 +1569,7 @@ TEST_F(FormatTestCSharp, NamespaceIndentation) {
                "public interface Name1\n"
                "{\n"
                "}\n"
-               "}\n",
+               "}",
                Style);
 
   Style.NamespaceIndentation = FormatStyle::NI_Inner;
@@ -1582,7 +1582,7 @@ TEST_F(FormatTestCSharp, NamespaceIndentation) {
                "    {\n"
                "    }\n"
                "}\n"
-               "}\n",
+               "}",
                Style);
 
   Style.NamespaceIndentation = FormatStyle::NI_All;
@@ -1592,7 +1592,7 @@ TEST_F(FormatTestCSharp, NamespaceIndentation) {
                "    public interface Name1\n"
                "    {\n"
                "    }\n"
-               "}\n",
+               "}",
                Style);
 
   verifyFormat("namespace A\n"
@@ -1603,7 +1603,7 @@ TEST_F(FormatTestCSharp, NamespaceIndentation) {
                "        {\n"
                "        }\n"
                "    }\n"
-               "}\n",
+               "}",
                Style);
 }
 
@@ -1613,7 +1613,7 @@ TEST_F(FormatTestCSharp, SwitchExpression) {
                "    1 => (0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0),\n"
                "    2 => 1,\n"
                "    _ => 2\n"
-               "};\n",
+               "};",
                Style);
 }
 
@@ -1625,12 +1625,12 @@ TEST_F(FormatTestCSharp, EmptyShortBlock) {
                "  doA();\n"
                "} catch (Exception e) {\n"
                "  e.printStackTrace();\n"
-               "}\n",
+               "}",
                Style);
 
   verifyFormat("try {\n"
                "  doA();\n"
-               "} catch (Exception e) {}\n",
+               "} catch (Exception e) {}",
                Style);
 }
 

diff  --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index 5e5324f01d8670a..967ffa32db79c75 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -27,15 +27,15 @@ TEST_F(FormatTestComments, UnderstandsSingleLineComments) {
   verifyFormat("//* */");
   verifyFormat("// line 1\n"
                "// line 2\n"
-               "void f() {}\n");
+               "void f() {}");
 
-  EXPECT_EQ("// comment\n", format("//comment\n"));
-  EXPECT_EQ("// #comment\n", format("//#comment\n"));
+  EXPECT_EQ("// comment", format("//comment"));
+  EXPECT_EQ("// #comment", format("//#comment"));
 
   EXPECT_EQ("// comment\n"
-            "// clang-format on\n",
+            "// clang-format on",
             format("//comment\n"
-                   "// clang-format on\n"));
+                   "// clang-format on"));
 
   verifyFormat("void f() {\n"
                "  // Doesn't do anything\n"
@@ -1237,11 +1237,11 @@ TEST_F(FormatTestComments, SplitsLongLinesInComments) {
   EXPECT_EQ("/*\n"
             "\n"
             "\n"
-            "    */\n",
+            "    */",
             format("  /*       \n"
                    "      \n"
                    "               \n"
-                   "      */\n"));
+                   "      */"));
 
   EXPECT_EQ("/* a a */",
             format("/* a a            */", getLLVMStyleWithColumns(15)));
@@ -1412,7 +1412,7 @@ TEST_F(FormatTestComments, CommentsInStaticInitializers) {
   verifyFormat("const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = {\n"
                "    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment\n"
                "    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment\n"
-               "    0x00, 0x00, 0x00, 0x00};            // comment\n");
+               "    0x00, 0x00, 0x00, 0x00};            // comment");
 }
 
 TEST_F(FormatTestComments, LineCommentsAfterRightBrace) {
@@ -1483,9 +1483,9 @@ TEST_F(FormatTestComments, ReflowsComments) {
 
   // Keep the trailing newline while reflowing.
   EXPECT_EQ("// long long long\n"
-            "// long long\n",
+            "// long long",
             format("// long long long long\n"
-                   "// long\n",
+                   "// long",
                    getLLVMStyleWithColumns(20)));
 
   // Break a long line and reflow with a part of the next line.
@@ -1499,9 +1499,9 @@ TEST_F(FormatTestComments, ReflowsComments) {
   // Break but do not reflow if the first word from the next line is too long.
   EXPECT_EQ("// long long long\n"
             "// long\n"
-            "// long_long_long\n",
+            "// long_long_long",
             format("// long long long long\n"
-                   "// long_long_long\n",
+                   "// long_long_long",
                    getLLVMStyleWithColumns(20)));
 
   // Don't break or reflow short lines.
@@ -1513,14 +1513,14 @@ TEST_F(FormatTestComments, ReflowsComments) {
 
   // Keep prefixes and decorations while reflowing.
   EXPECT_EQ("/// long long long\n"
-            "/// long long\n",
+            "/// long long",
             format("/// long long long long\n"
-                   "/// long\n",
+                   "/// long",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("//! long long long\n"
-            "//! long long\n",
+            "//! long long",
             format("//! long long long long\n"
-                   "//! long\n",
+                   "//! long",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("/* long long long\n"
             " * long long */",
@@ -1528,14 +1528,14 @@ TEST_F(FormatTestComments, ReflowsComments) {
                    " * long */",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("///< long long long\n"
-            "///< long long\n",
+            "///< long long",
             format("///< long long long long\n"
-                   "///< long\n",
+                   "///< long",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("//!< long long long\n"
-            "//!< long long\n",
+            "//!< long long",
             format("//!< long long long long\n"
-                   "//!< long\n",
+                   "//!< long",
                    getLLVMStyleWithColumns(20)));
 
   // Don't bring leading whitespace up while reflowing.
@@ -1623,9 +1623,9 @@ TEST_F(FormatTestComments, ReflowsComments) {
   // multiple lines.
   EXPECT_EQ("// long long long\n"
             "// long long long\n"
-            "// long long long\n",
+            "// long long long",
             format("// long long long long long long long long\n"
-                   "// long\n",
+                   "// long",
                    getLLVMStyleWithColumns(20)));
 
   // Break the first line, then reflow the beginning of the second and third
@@ -1707,39 +1707,39 @@ TEST_F(FormatTestComments, ReflowsComments) {
   EXPECT_EQ("int a; // Trailing\n"
             "       // comment on\n"
             "       // 2 or 3\n"
-            "       // lines.\n",
+            "       // lines.",
             format("int a; // Trailing comment\n"
                    "       // on 2\n"
                    "       // or 3\n"
-                   "       // lines.\n",
+                   "       // lines.",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("/// This long line\n"
-            "/// gets reflown.\n",
+            "/// gets reflown.",
             format("/// This long line gets\n"
-                   "/// reflown.\n",
+                   "/// reflown.",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("//! This long line\n"
-            "//! gets reflown.\n",
+            "//! gets reflown.",
             format(" //! This long line gets\n"
-                   " //! reflown.\n",
+                   " //! reflown.",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("/* This long line\n"
             " * gets reflown.\n"
-            " */\n",
+            " */",
             format("/* This long line gets\n"
                    " * reflown.\n"
-                   " */\n",
+                   " */",
                    getLLVMStyleWithColumns(20)));
 
   // Reflow after indentation makes a line too long.
   EXPECT_EQ("{\n"
             "  // long long long\n"
             "  // lo long\n"
-            "}\n",
+            "}",
             format("{\n"
                    "// long long long lo\n"
                    "// long\n"
-                   "}\n",
+                   "}",
                    getLLVMStyleWithColumns(20)));
 
   // Break and reflow multiple lines.
@@ -1747,7 +1747,7 @@ TEST_F(FormatTestComments, ReflowsComments) {
             " * Reflow the end of\n"
             " * line by 11 22 33\n"
             " * 4.\n"
-            " */\n",
+            " */",
             format("/*\n"
                    " * Reflow the end of line\n"
                    " * by\n"
@@ -1755,23 +1755,23 @@ TEST_F(FormatTestComments, ReflowsComments) {
                    " * 22\n"
                    " * 33\n"
                    " * 4.\n"
-                   " */\n",
+                   " */",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("/// First line gets\n"
             "/// broken. Second\n"
             "/// line gets\n"
             "/// reflown and\n"
             "/// broken. Third\n"
-            "/// gets reflown.\n",
+            "/// gets reflown.",
             format("/// First line gets broken.\n"
                    "/// Second line gets reflown and broken.\n"
-                   "/// Third gets reflown.\n",
+                   "/// Third gets reflown.",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("int i; // first long\n"
             "       // long snd\n"
-            "       // long.\n",
+            "       // long.",
             format("int i; // first long long\n"
-                   "       // snd long.\n",
+                   "       // snd long.",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("{\n"
             "  // first long line\n"
@@ -1779,12 +1779,12 @@ TEST_F(FormatTestComments, ReflowsComments) {
             "  // long line line\n"
             "  // third long line\n"
             "  // line\n"
-            "}\n",
+            "}",
             format("{\n"
                    "  // first long line line\n"
                    "  // second long line line\n"
                    "  // third long line line\n"
-                   "}\n",
+                   "}",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("int i; /* first line\n"
             "        * second\n"
@@ -1809,20 +1809,20 @@ TEST_F(FormatTestComments, ReflowsComments) {
 
   // Keep the block comment endling '*/' while reflowing.
   EXPECT_EQ("/* Long long long\n"
-            " * line short */\n",
+            " * line short */",
             format("/* Long long long line\n"
-                   " * short */\n",
+                   " * short */",
                    getLLVMStyleWithColumns(20)));
 
   // Don't reflow between separate blocks of comments.
   EXPECT_EQ("/* First comment\n"
             " * block will */\n"
             "/* Snd\n"
-            " */\n",
+            " */",
             format("/* First comment block\n"
                    " * will */\n"
                    "/* Snd\n"
-                   " */\n",
+                   " */",
                    getLLVMStyleWithColumns(20)));
 
   // Don't reflow across blank comment lines.
@@ -1830,10 +1830,10 @@ TEST_F(FormatTestComments, ReflowsComments) {
             "       // line gets\n"
             "       // broken.\n"
             "       //\n"
-            "       // keep.\n",
+            "       // keep.",
             format("int i; // This long line gets broken.\n"
                    "       //  \n"
-                   "       // keep.\n",
+                   "       // keep.",
                    getLLVMStyleWithColumns(20)));
   EXPECT_EQ("{\n"
             "  /// long long long\n"
@@ -1949,11 +1949,11 @@ TEST_F(FormatTestComments, ReflowsComments) {
   EXPECT_EQ("/* First comment\n"
             " * block will */\n"
             "/* Snd\n"
-            " */\n",
+            " */",
             format("/* First comment block\n"
                    " * will */\n"
                    "/* Snd\n"
-                   " */\n",
+                   " */",
                    getLLVMStyleWithColumns(20)));
 
   // Don't reflow lines having 
diff erent indentation.
@@ -2043,18 +2043,18 @@ TEST_F(FormatTestComments, ReflowsComments) {
   EXPECT_EQ("int i; // long long\n"
             "       // long\n"
             "int j; // long long\n"
-            "       // long\n",
+            "       // long",
             format("int i; // long long long\n"
-                   "int j; // long long long\n",
+                   "int j; // long long long",
                    getLLVMStyleWithColumns(20)));
 
   // Don't reflow if the first word on the next line is longer than the
   // available space at current line.
   EXPECT_EQ("int i; // trigger\n"
             "       // reflow\n"
-            "       // longsec\n",
+            "       // longsec",
             format("int i; // trigger reflow\n"
-                   "       // longsec\n",
+                   "       // longsec",
                    getLLVMStyleWithColumns(20)));
 
   // Simple case that correctly handles reflow in parameter lists.
@@ -2089,16 +2089,16 @@ TEST_F(FormatTestComments, ReflowsCommentsPrecise) {
   // After reflowing, "// reflows into   foo" does not fit the column limit,
   // so we compress the whitespace.
   EXPECT_EQ("// some text that\n"
-            "// reflows into foo\n",
+            "// reflows into foo",
             format("// some text that reflows\n"
-                   "// into   foo\n",
+                   "// into   foo",
                    getLLVMStyleWithColumns(20)));
   // Given one more column, "// reflows into   foo" does fit the limit, so we
   // do not compress the whitespace.
   EXPECT_EQ("// some text that\n"
-            "// reflows into   foo\n",
+            "// reflows into   foo",
             format("// some text that reflows\n"
-                   "// into   foo\n",
+                   "// into   foo",
                    getLLVMStyleWithColumns(21)));
 
   // Make sure that we correctly account for the space added in the reflow case
@@ -2107,56 +2107,56 @@ TEST_F(FormatTestComments, ReflowsCommentsPrecise) {
   // reflow.
   EXPECT_EQ("// some text that\n"
             "// reflows\n"
-            "// into1234567\n",
+            "// into1234567",
             format("// some text that reflows\n"
-                   "// into1234567\n",
+                   "// into1234567",
                    getLLVMStyleWithColumns(21)));
   // Secondly, when the next line ends later, but the first word in that line
   // is precisely one column over the limit, do not reflow.
   EXPECT_EQ("// some text that\n"
             "// reflows\n"
-            "// into1234567 f\n",
+            "// into1234567 f",
             format("// some text that reflows\n"
-                   "// into1234567 f\n",
+                   "// into1234567 f",
                    getLLVMStyleWithColumns(21)));
 }
 
 TEST_F(FormatTestComments, ReflowsCommentsWithExtraWhitespace) {
   // Baseline.
   EXPECT_EQ("// some text\n"
-            "// that re flows\n",
+            "// that re flows",
             format("// some text that\n"
-                   "// re flows\n",
+                   "// re flows",
                    getLLVMStyleWithColumns(16)));
   EXPECT_EQ("// some text\n"
-            "// that re flows\n",
+            "// that re flows",
             format("// some text that\n"
-                   "// re    flows\n",
+                   "// re    flows",
                    getLLVMStyleWithColumns(16)));
   EXPECT_EQ("/* some text\n"
             " * that re flows\n"
-            " */\n",
+            " */",
             format("/* some text that\n"
                    "*      re       flows\n"
-                   "*/\n",
+                   "*/",
                    getLLVMStyleWithColumns(16)));
   // FIXME: We do not reflow if the indent of two subsequent lines 
diff ers;
   // given that this is 
diff erent behavior from block comments, do we want
   // to keep this?
   EXPECT_EQ("// some text\n"
             "// that\n"
-            "//     re flows\n",
+            "//     re flows",
             format("// some text that\n"
-                   "//     re       flows\n",
+                   "//     re       flows",
                    getLLVMStyleWithColumns(16)));
   // Space within parts of a line that fit.
   // FIXME: Use the earliest possible split while reflowing to compress the
   // whitespace within the line.
   EXPECT_EQ("// some text that\n"
             "// does re   flow\n"
-            "// more  here\n",
+            "// more  here",
             format("// some text that does\n"
-                   "// re   flow  more  here\n",
+                   "// re   flow  more  here",
                    getLLVMStyleWithColumns(21)));
 }
 
@@ -2172,11 +2172,11 @@ TEST_F(FormatTestComments, IgnoresIf0Contents) {
   EXPECT_EQ("#if false\n"
             "void f(  ) {  }\n"
             "#endif\n"
-            "void g() {}\n",
+            "void g() {}",
             format("#if false\n"
                    "void f(  ) {  }\n"
                    "#endif\n"
-                   "void g(  ) {  }\n"));
+                   "void g(  ) {  }"));
   EXPECT_EQ("enum E {\n"
             "  One,\n"
             "  Two,\n"
@@ -2420,10 +2420,10 @@ TEST_F(FormatTestComments, BlockComments) {
   EXPECT_EQ(
       "int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; /* comment */\n"
       "int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;   /* comment */\n"
-      "int cccccccccccccccccccccccccccccc;       /* comment */\n",
+      "int cccccccccccccccccccccccccccccc;       /* comment */",
       format("int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; /* comment */\n"
              "int      bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; /* comment */\n"
-             "int    cccccccccccccccccccccccccccccc;  /* comment */\n"));
+             "int    cccccccccccccccccccccccccccccc;  /* comment */"));
 
   verifyFormat("void f(int * /* unused */) {}");
 
@@ -2595,9 +2595,9 @@ TEST_F(FormatTestComments, AlignTrailingComments) {
   // Align newly broken trailing comments.
   EXPECT_EQ("int ab; // line\n"
             "int a;  // long\n"
-            "        // long\n",
+            "        // long",
             format("int ab; // line\n"
-                   "int a; // long long\n",
+                   "int a; // long long",
                    getLLVMStyleWithColumns(15)));
   EXPECT_EQ("int ab; // line\n"
             "int a;  // long\n"
@@ -2768,7 +2768,7 @@ TEST_F(FormatTestComments, AlignTrailingComments) {
       "#if BAR\n"
       "#else\n"
       "long b_long_name; // Line about b\n"
-      "#endif\n",
+      "#endif",
       format("#if FOO\n"
              "#else\n"
              "long a;           // Line about a\n" // Previous (bad) behavior
@@ -2776,7 +2776,7 @@ TEST_F(FormatTestComments, AlignTrailingComments) {
              "#if BAR\n"
              "#else\n"
              "long b_long_name; // Line about b\n"
-             "#endif\n",
+             "#endif",
              getLLVMStyleWithColumns(80)));
 
   // bug 47589
@@ -2787,21 +2787,21 @@ TEST_F(FormatTestComments, AlignTrailingComments) {
       "#define FOO_SITELOCAL 2   // Site-local scope (deprecated).\n"
       "#define FOO_UNIQUELOCAL 3 // Unique local\n"
       "#define FOO_NODELOCAL 4   // Loopback\n\n"
-      "} // namespace m\n",
+      "} // namespace m",
       format("namespace m {\n\n"
              "#define FOO_GLOBAL 0   // Global scope.\n"
              "#define FOO_LINKLOCAL 1  // Link-local scope.\n"
              "#define FOO_SITELOCAL 2  // Site-local scope (deprecated).\n"
              "#define FOO_UNIQUELOCAL 3 // Unique local\n"
              "#define FOO_NODELOCAL 4  // Loopback\n\n"
-             "} // namespace m\n",
+             "} // namespace m",
              getLLVMStyleWithColumns(80)));
 
   // https://llvm.org/PR53441
   verifyFormat("/* */  //\n"
-               "int a; //\n");
+               "int a; //");
   verifyFormat("/**/   //\n"
-               "int a; //\n");
+               "int a; //");
 }
 
 TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
@@ -2810,14 +2810,14 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
   Style.AlignTrailingComments.OverEmptyLines = 1;
   verifyFormat("#include \"a.h\"  // simple\n"
                "\n"
-               "#include \"aa.h\" // example case\n",
+               "#include \"aa.h\" // example case",
                Style);
 
   verifyFormat("#include \"a.h\"   // align across\n"
                "\n"
                "#include \"aa.h\"  // two empty lines\n"
                "\n"
-               "#include \"aaa.h\" // in a row\n",
+               "#include \"aaa.h\" // in a row",
                Style);
 
   verifyFormat("#include \"a.h\"      // align\n"
@@ -2826,19 +2826,19 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
                "\n"
                "#include \"aaaa.h\"   // across\n"
                "#include \"aaaaa.h\"  // one\n"
-               "#include \"aaaaaa.h\" // empty line\n",
+               "#include \"aaaaaa.h\" // empty line",
                Style);
 
   verifyFormat("#include \"a.h\"  // align trailing comments\n"
                "#include \"a.h\"\n"
-               "#include \"aa.h\" // across a line without comment\n",
+               "#include \"aa.h\" // across a line without comment",
                Style);
 
   verifyFormat("#include \"a.h\"   // align across\n"
                "#include \"a.h\"\n"
                "#include \"aa.h\"  // two lines without comment\n"
                "#include \"a.h\"\n"
-               "#include \"aaa.h\" // in a row\n",
+               "#include \"aaa.h\" // in a row",
                Style);
 
   verifyFormat("#include \"a.h\"      // align\n"
@@ -2847,7 +2847,7 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
                "#include \"a.h\"\n"
                "#include \"aaaa.h\"   // across\n"
                "#include \"aaaaa.h\"  // a line without\n"
-               "#include \"aaaaaa.h\" // comment\n",
+               "#include \"aaaaaa.h\" // comment",
                Style);
 
   // Start of testing OverEmptyLines
@@ -2862,7 +2862,7 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
             "#include \"ab.h\"      // comment\n"
             "\n"
             "\n"
-            "#include \"abcdefg.h\" // comment\n",
+            "#include \"abcdefg.h\" // comment",
             format("#include \"a.h\" // comment\n"
                    "\n"
                    "\n"
@@ -2870,7 +2870,7 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
                    "#include \"ab.h\" // comment\n"
                    "\n"
                    "\n"
-                   "#include \"abcdefg.h\" // comment\n",
+                   "#include \"abcdefg.h\" // comment",
                    Style));
 
   Style.MaxEmptyLinesToKeep = 1;
@@ -2893,10 +2893,10 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
   EXPECT_EQ("int ab; // line\n"
             "\n"
             "int a;  // long\n"
-            "        // long\n",
+            "        // long",
             format("int ab; // line\n"
                    "\n"
-                   "int a; // long long\n",
+                   "int a; // long long",
                    Style));
 
   Style.ColumnLimit = 30;
@@ -2908,12 +2908,12 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
             "           // arround.\n"
             "\n"
             "int x = 2; // Is this still\n"
-            "           // aligned?\n",
+            "           // aligned?",
             format("int foo = 12345; // comment\n"
                    "int bar = 1234; // This is a very long comment\n"
                    "                // which is wrapped arround.\n"
                    "\n"
-                   "int x = 2; // Is this still aligned?\n",
+                   "int x = 2; // Is this still aligned?",
                    Style));
 
   Style.ColumnLimit = 35;
@@ -2924,12 +2924,12 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
             "          // wrapped arround.\n"
             "\n"
             "int x =\n"
-            "    2; // Is this still aligned?\n",
+            "    2; // Is this still aligned?",
             format("int foo = 12345; // comment\n"
                    "int bar = 1234; // This is a very long comment\n"
                    "                // which is wrapped arround.\n"
                    "\n"
-                   "int x = 2; // Is this still aligned?\n",
+                   "int x = 2; // Is this still aligned?",
                    Style));
 
   Style.ColumnLimit = 40;
@@ -2938,12 +2938,12 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
             "    1234; // This is a very long comment\n"
             "          // which is wrapped arround.\n"
             "\n"
-            "int x = 2; // Is this still aligned?\n",
+            "int x = 2; // Is this still aligned?",
             format("int foo = 12345; // comment\n"
                    "int bar = 1234; // This is a very long comment\n"
                    "                // which is wrapped arround.\n"
                    "\n"
-                   "int x = 2; // Is this still aligned?\n",
+                   "int x = 2; // Is this still aligned?",
                    Style));
 
   Style.ColumnLimit = 45;
@@ -2952,12 +2952,12 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
             "    1234;  // This is a very long comment\n"
             "           // which is wrapped arround.\n"
             "\n"
-            "int x = 2; // Is this still aligned?\n",
+            "int x = 2; // Is this still aligned?",
             format("int foo = 12345; // comment\n"
                    "int bar = 1234; // This is a very long comment\n"
                    "                // which is wrapped arround.\n"
                    "\n"
-                   "int x = 2; // Is this still aligned?\n",
+                   "int x = 2; // Is this still aligned?",
                    Style));
 
   Style.ColumnLimit = 80;
@@ -2992,21 +2992,21 @@ TEST_F(FormatTestComments, AlignTrailingCommentsLeave) {
   EXPECT_EQ("int a;// do not touch\n"
             "int b; // any comments\n"
             "int c;  // comment\n"
-            "int d;   // comment\n",
+            "int d;   // comment",
             format("int a;// do not touch\n"
                    "int b; // any comments\n"
                    "int c;  // comment\n"
-                   "int d;   // comment\n",
+                   "int d;   // comment",
                    Style));
 
   EXPECT_EQ("int a;   // do not touch\n"
             "int b;  // any comments\n"
             "int c; // comment\n"
-            "int d;// comment\n",
+            "int d;// comment",
             format("int a;   // do not touch\n"
                    "int b;  // any comments\n"
                    "int c; // comment\n"
-                   "int d;// comment\n",
+                   "int d;// comment",
                    Style));
 
   EXPECT_EQ("// do not touch\n"
@@ -3086,10 +3086,10 @@ TEST_F(FormatTestComments, AlignTrailingCommentsLeave) {
             "int bar =\n"
             "    1234; // This is a very long\n"
             "          // comment which is\n"
-            "          // wrapped arround.\n",
+            "          // wrapped arround.",
             format("int foo = 12345; // comment\n"
                    "int bar = 1234;       // This is a very long comment\n"
-                   "          // which is wrapped arround.\n",
+                   "          // which is wrapped arround.",
                    Style));
 }
 
@@ -3671,41 +3671,41 @@ TEST_F(FormatTestComments, IndentsLongJavadocAnnotatedLines) {
       "/**\n"
       " * @param x long long long long long long long long long\n"
       " *     long\n"
-      " */\n",
+      " */",
       format("/**\n"
              " * @param x long long long long long long long long long long\n"
-             " */\n",
+             " */",
              Style));
   EXPECT_EQ("/**\n"
             " * @param x long long long long long long long long long\n"
             " *     long long long long long long long long long long\n"
-            " */\n",
+            " */",
             format("/**\n"
                    " * @param x long long long long long long long long long "
                    "long long long long long long long long long long\n"
-                   " */\n",
+                   " */",
                    Style));
   EXPECT_EQ("/**\n"
             " * @param x long long long long long long long long long\n"
             " *     long long long long long long long long long long\n"
             " *     long\n"
-            " */\n",
+            " */",
             format("/**\n"
                    " * @param x long long long long long long long long long "
                    "long long long long long long long long long long long\n"
-                   " */\n",
+                   " */",
                    Style));
   EXPECT_EQ("/**\n"
             " * Sentence that\n"
             " * should be broken.\n"
             " * @param short\n"
             " * keep indentation\n"
-            " */\n",
+            " */",
             format("/**\n"
                    " * Sentence that should be broken.\n"
                    " * @param short\n"
                    " * keep indentation\n"
-                   " */\n",
+                   " */",
                    Style20));
 
   EXPECT_EQ("/**\n"
@@ -3713,33 +3713,33 @@ TEST_F(FormatTestComments, IndentsLongJavadocAnnotatedLines) {
             " *     to break\n"
             " * @param l2 long2\n"
             " *     to break\n"
-            " */\n",
+            " */",
             format("/**\n"
                    " * @param l1 long1 to break\n"
                    " * @param l2 long2 to break\n"
-                   " */\n",
+                   " */",
                    Style20));
 
   EXPECT_EQ("/**\n"
             " * @param xx to\n"
             " *     break\n"
             " * no reflow\n"
-            " */\n",
+            " */",
             format("/**\n"
                    " * @param xx to break\n"
                    " * no reflow\n"
-                   " */\n",
+                   " */",
                    Style20));
 
   EXPECT_EQ("/**\n"
             " * @param xx to\n"
             " *     break yes\n"
             " *     reflow\n"
-            " */\n",
+            " */",
             format("/**\n"
                    " * @param xx to break\n"
                    " *     yes reflow\n"
-                   " */\n",
+                   " */",
                    Style20));
 
   FormatStyle JSStyle20 = getGoogleStyle(FormatStyle::LK_JavaScript);
@@ -3747,18 +3747,18 @@ TEST_F(FormatTestComments, IndentsLongJavadocAnnotatedLines) {
   EXPECT_EQ("/**\n"
             " * @param l1 long1\n"
             " *     to break\n"
-            " */\n",
+            " */",
             format("/**\n"
                    " * @param l1 long1 to break\n"
-                   " */\n",
+                   " */",
                    JSStyle20));
   EXPECT_EQ("/**\n"
             " * @param {l1 long1\n"
             " *     to break}\n"
-            " */\n",
+            " */",
             format("/**\n"
                    " * @param {l1 long1 to break}\n"
-                   " */\n",
+                   " */",
                    JSStyle20));
 }
 
@@ -3866,7 +3866,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
       "//} will not move\n"
       "\n"
       "//vv will only move\n"
-      "//} if the line above does\n";
+      "//} if the line above does";
 
   EXPECT_EQ("// Free comment without space\n"
             "\n"
@@ -3937,7 +3937,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             "//} will not move\n"
             "\n"
             "// vv will only move\n"
-            "// } if the line above does\n",
+            "// } if the line above does",
             format(Code, Style));
 
   Style.SpacesInLineCommentPrefix = {0, 0};
@@ -4011,7 +4011,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             "//} will not move\n"
             "\n"
             "//vv will only move\n"
-            "//} if the line above does\n",
+            "//} if the line above does",
             format(Code, Style));
 
   Style.SpacesInLineCommentPrefix = {2, -1u};
@@ -4084,7 +4084,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             "//} will not move\n"
             "\n"
             "//  vv will only move\n"
-            "//  } if the line above does\n",
+            "//  } if the line above does",
             format(Code, Style));
 
   Style = getLLVMStyleWithColumns(20);
@@ -4271,7 +4271,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             "\n"
             "//    A Comment to\n"
             "//    be moved\n"
-            "//     with indent\n",
+            "//     with indent",
             format("//A Comment to be moved\n"
                    "// with indent\n"
                    "\n"
@@ -4291,7 +4291,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
                    "//      with indent\n"
                    "\n"
                    "//      A Comment to be moved\n"
-                   "//       with indent\n",
+                   "//       with indent",
                    Style));
 
   Style.ColumnLimit = 30;
@@ -4321,7 +4321,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             "\n"
             "int i; //    A Comment to be\n"
             "       //    moved\n"
-            "       //     with indent\n",
+            "       //     with indent",
             format("int i;//A Comment to be moved\n"
                    "      // with indent\n"
                    "\n"
@@ -4341,7 +4341,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
                    "      //      with indent\n"
                    "\n"
                    "int i;//      A Comment to be moved\n"
-                   "      //       with indent\n",
+                   "      //       with indent",
                    Style));
 
   Style = getLLVMStyleWithColumns(0);
@@ -4414,7 +4414,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             "//} will not move\n"
             "\n"
             "// vv will only move\n"
-            "// } if the line above does\n",
+            "// } if the line above does",
             format(Code, Style));
 
   Style.SpacesInLineCommentPrefix = {0, 0};
@@ -4487,7 +4487,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             "//} will not move\n"
             "\n"
             "//vv will only move\n"
-            "//} if the line above does\n",
+            "//} if the line above does",
             format(Code, Style));
 
   Style.SpacesInLineCommentPrefix = {2, -1u};
@@ -4560,7 +4560,7 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
             "//} will not move\n"
             "\n"
             "//  vv will only move\n"
-            "//  } if the line above does\n",
+            "//  } if the line above does",
             format(Code, Style));
 }
 

diff  --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index f3bf70ab40b3711..202d603d0577909 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -221,7 +221,7 @@ TEST_F(FormatTestJava, EnumDeclarations) {
                "\"cccccccccccccccccccccccc\"),\n"
                "  SECOND_ENUM(\"a\", \"b\", \"c\");\n"
                "  private VeryLongEnum(String a, String b, String c) {}\n"
-               "}\n");
+               "}");
 }
 
 TEST_F(FormatTestJava, ArrayInitializers) {

diff  --git a/clang/unittests/Format/FormatTestMacroExpansion.cpp b/clang/unittests/Format/FormatTestMacroExpansion.cpp
index bc698c60c107d1d..68250234f4201ef 100644
--- a/clang/unittests/Format/FormatTestMacroExpansion.cpp
+++ b/clang/unittests/Format/FormatTestMacroExpansion.cpp
@@ -55,11 +55,11 @@ TEST_F(FormatTestMacroExpansion, UnexpandConfiguredMacros) {
   verifyFormat("ID(CALL(CALL(return a * b;)));", Style);
 
   verifyFormat("ASSIGN_OR_RETURN(MySomewhatLongType *variable,\n"
-               "                 MySomewhatLongFunction(SomethingElse()));\n",
+               "                 MySomewhatLongFunction(SomethingElse()));",
                Style);
   verifyFormat("ASSIGN_OR_RETURN(MySomewhatLongType *variable,\n"
                "                 MySomewhatLongFunction(SomethingElse()), "
-               "ReturnMe());\n",
+               "ReturnMe());",
                Style);
 
   verifyFormat(R"(

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 290d0103bb3cf87..ce4d026207499c9 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -90,7 +90,7 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
   EXPECT_EQ(Tokens.size(), 5u) << Tokens;
   EXPECT_TOKEN(Tokens[1], tok::amp, TT_UnaryOperator);
 
-  Tokens = annotate("bool b = 3 == int{3} && true;\n");
+  Tokens = annotate("bool b = 3 == int{3} && true;");
   EXPECT_EQ(Tokens.size(), 13u) << Tokens;
   EXPECT_TOKEN(Tokens[9], tok::ampamp, TT_BinaryOperator);
 
@@ -542,11 +542,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsWhitespaceSensitiveMacros) {
   FormatStyle Style = getLLVMStyle();
   Style.WhitespaceSensitiveMacros.push_back("FOO");
 
-  auto Tokens = annotate("FOO(1+2 )\n", Style);
+  auto Tokens = annotate("FOO(1+2 )", Style);
   EXPECT_EQ(Tokens.size(), 7u) << Tokens;
   EXPECT_TOKEN(Tokens[0], tok::identifier, TT_UntouchableMacroFunc);
 
-  Tokens = annotate("FOO(a:b:c)\n", Style);
+  Tokens = annotate("FOO(a:b:c)", Style);
   EXPECT_EQ(Tokens.size(), 9u) << Tokens;
   EXPECT_TOKEN(Tokens[0], tok::identifier, TT_UntouchableMacroFunc);
 }
@@ -2030,13 +2030,13 @@ TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) {
   Tokens = Annotate("case (x)\n"
                     "  x:\n"
                     "    x;\n"
-                    "endcase\n");
+                    "endcase");
   ASSERT_EQ(Tokens.size(), 10u) << Tokens;
   EXPECT_TOKEN(Tokens[5], tok::colon, TT_CaseLabelColon);
   Tokens = Annotate("case (x)\n"
                     "  x ? x : x:\n"
                     "    x;\n"
-                    "endcase\n");
+                    "endcase");
   ASSERT_EQ(Tokens.size(), 14u) << Tokens;
   EXPECT_TOKEN(Tokens[5], tok::question, TT_ConditionalExpr);
   EXPECT_TOKEN(Tokens[7], tok::colon, TT_ConditionalExpr);


        


More information about the cfe-commits mailing list