[clang] 8411bdb - [clang-format][NFC] Remove redundant getLLVMStyle() in unit tests

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 17 15:26:07 PDT 2023


Author: Owen Pan
Date: 2023-06-17T15:25:59-07:00
New Revision: 8411bdb0acde8569c9bfcd08401fa587f7dea834

URL: https://github.com/llvm/llvm-project/commit/8411bdb0acde8569c9bfcd08401fa587f7dea834
DIFF: https://github.com/llvm/llvm-project/commit/8411bdb0acde8569c9bfcd08401fa587f7dea834.diff

LOG: [clang-format][NFC] Remove redundant getLLVMStyle() in unit tests

Added: 
    

Modified: 
    clang/unittests/Format/FormatTest.cpp
    clang/unittests/Format/FormatTestComments.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index ebf5850da439a..4c58df893aa8f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -312,8 +312,7 @@ TEST_F(FormatTest, RemovesEmptyLines) {
                    "\n"
                    "  }\n"
                    "\n"
-                   "}",
-                   getLLVMStyle()));
+                   "}"));
   EXPECT_EQ("void f() {\n"
             "  if (a) {\n"
             "    f();\n"
@@ -2565,8 +2564,7 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
                    "    g();\n"
                    "    break;\n"
                    "  }\n"
-                   "});",
-                   getLLVMStyle()));
+                   "});"));
   EXPECT_EQ("switch (n) {\n"
             "case 0: {\n"
             "  return false;\n"
@@ -2583,8 +2581,7 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
                    "default: {\n"
                    "  return true;\n"
                    "}\n"
-                   "}",
-                   getLLVMStyle()));
+                   "}"));
   verifyFormat("switch (a) {\n"
                "case (b):\n"
                "  return;\n"
@@ -5512,14 +5509,14 @@ TEST_F(FormatTest, MacroDefinitionInsideStatement) {
 }
 
 TEST_F(FormatTest, HashInMacroDefinition) {
-  verifyFormat("#define A(c) L#c", getLLVMStyle());
-  verifyFormat("#define A(c) u#c", getLLVMStyle());
-  verifyFormat("#define A(c) U#c", getLLVMStyle());
-  verifyFormat("#define A(c) u8#c", getLLVMStyle());
-  verifyFormat("#define A(c) LR#c", getLLVMStyle());
-  verifyFormat("#define A(c) uR#c", getLLVMStyle());
-  verifyFormat("#define A(c) UR#c", getLLVMStyle());
-  verifyFormat("#define A(c) u8R#c", getLLVMStyle());
+  verifyFormat("#define A(c) L#c");
+  verifyFormat("#define A(c) u#c");
+  verifyFormat("#define A(c) U#c");
+  verifyFormat("#define A(c) u8#c");
+  verifyFormat("#define A(c) LR#c");
+  verifyFormat("#define A(c) uR#c");
+  verifyFormat("#define A(c) UR#c");
+  verifyFormat("#define A(c) u8R#c");
   verifyFormat("#define A \\\n  b #c;", getLLVMStyleWithColumns(11));
   verifyFormat("#define A  \\\n"
                "  {        \\\n"
@@ -12192,8 +12189,7 @@ TEST_F(FormatTest, BreaksLongDeclarations) {
 
   verifyFormat("template <typename T> // Templates on own line.\n"
                "static int            // Some comment.\n"
-               "MyFunction(int a);",
-               getLLVMStyle());
+               "MyFunction(int a);");
 }
 
 TEST_F(FormatTest, FormatsAccessModifiers) {
@@ -16202,15 +16198,13 @@ TEST_F(FormatTest, CalculatesOriginalColumn) {
             "       comment */",
             format("  \"qqqqqqqqqqqqqqqqqqqqqqqqqq\\\n"
                    "q\"; /* some\n"
-                   "       comment */",
-                   getLLVMStyle()));
+                   "       comment */"));
   EXPECT_EQ("// qqqqqqqqqqqqqqqqqqqqqqqqqq\n"
             "/* some\n"
             "   comment */",
             format("// qqqqqqqqqqqqqqqqqqqqqqqqqq\n"
                    " /* some\n"
-                   "    comment */",
-                   getLLVMStyle()));
+                   "    comment */"));
   EXPECT_EQ("// qqqqqqqqqqqqqqqqqqqqqqqqqq\\\n"
             "qqq\n"
             "/* some\n"
@@ -16218,15 +16212,13 @@ TEST_F(FormatTest, CalculatesOriginalColumn) {
             format("// qqqqqqqqqqqqqqqqqqqqqqqqqq\\\n"
                    "qqq\n"
                    " /* some\n"
-                   "    comment */",
-                   getLLVMStyle()));
+                   "    comment */"));
   EXPECT_EQ("inttt qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\\\n"
             "wwww; /* some\n"
             "         comment */",
             format("  inttt qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\\\n"
                    "wwww; /* some\n"
-                   "         comment */",
-                   getLLVMStyle()));
+                   "         comment */"));
 }
 
 TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
@@ -20416,8 +20408,7 @@ TEST_F(FormatTest, CatchExceptionReferenceBinding) {
                "  try {\n"
                "  } catch (const Exception &e) {\n"
                "  }\n"
-               "}\n",
-               getLLVMStyle());
+               "}\n");
 }
 
 TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) {
@@ -22669,22 +22660,19 @@ TEST_F(FormatTest, SupportsCRLF) {
             "int c;\r\n",
             format("int a;\r\n"
                    "  int b;\r\n"
-                   "    int c;\r\n",
-                   getLLVMStyle()));
+                   "    int c;\r\n"));
   EXPECT_EQ("int a;\r\n"
             "int b;\r\n"
             "int c;\r\n",
             format("int a;\r\n"
                    "  int b;\n"
-                   "    int c;\r\n",
-                   getLLVMStyle()));
+                   "    int c;\r\n"));
   EXPECT_EQ("int a;\n"
             "int b;\n"
             "int c;\n",
             format("int a;\r\n"
                    "  int b;\n"
-                   "    int c;\n",
-                   getLLVMStyle()));
+                   "    int c;\n"));
   EXPECT_EQ("\"aaaaaaa \"\r\n"
             "\"bbbbbbb\";\r\n",
             format("\"aaaaaaa bbbbbbb\";\r\n", getLLVMStyleWithColumns(10)));
@@ -23211,16 +23199,16 @@ TEST_F(FormatTest, StructuredBindings) {
   FormatStyle PointerMiddle = getLLVMStyle();
   PointerMiddle.PointerAlignment = FormatStyle::PAS_Middle;
   verifyGoogleFormat("auto [a1, b]{A * i};");
-  verifyFormat("auto [a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto [a2, b]{A * i};");
   verifyFormat("auto [a3, b]{A * i};", PointerMiddle);
   verifyGoogleFormat("auto const [a1, b]{A * i};");
-  verifyFormat("auto const [a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const [a2, b]{A * i};");
   verifyFormat("auto const [a3, b]{A * i};", PointerMiddle);
   verifyGoogleFormat("auto const& [a1, b]{A * i};");
-  verifyFormat("auto const &[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const &[a2, b]{A * i};");
   verifyFormat("auto const & [a3, b]{A * i};", PointerMiddle);
   verifyGoogleFormat("auto const&& [a1, b]{A * i};");
-  verifyFormat("auto const &&[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const &&[a2, b]{A * i};");
   verifyFormat("auto const && [a3, b]{A * i};", PointerMiddle);
 
   EXPECT_EQ("for (const auto &&[a, b] : some_range) {\n}",

diff  --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index 15c6767fc16ad..b0ba00caeeb44 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -565,12 +565,12 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
   EXPECT_EQ("//! Add leading\n"
             "//! whitespace",
             format("//!Add leading whitespace", getLLVMStyleWithColumns(20)));
-  EXPECT_EQ("// whitespace", format("//whitespace", getLLVMStyle()));
+  EXPECT_EQ("// whitespace", format("//whitespace"));
   EXPECT_EQ("// Even if it makes the line exceed the column\n"
             "// limit",
             format("//Even if it makes the line exceed the column limit",
                    getLLVMStyleWithColumns(51)));
-  verifyFormat("//--But not here", getLLVMStyle());
+  verifyFormat("//--But not here");
   EXPECT_EQ("/// line 1\n"
             "// add leading whitespace",
             format("/// line 1\n"
@@ -3076,65 +3076,53 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
   EXPECT_EQ("/*\n"
             " */",
             format("/*\n"
-                   "*/",
-                   getLLVMStyle()));
+                   "*/"));
   EXPECT_EQ("/*\n"
             " */",
             format("/*\n"
-                   " */",
-                   getLLVMStyle()));
+                   " */"));
   EXPECT_EQ("/*\n"
             " */",
             format("/*\n"
-                   "  */",
-                   getLLVMStyle()));
+                   "  */"));
 
   // Align a single line.
   EXPECT_EQ("/*\n"
             " * line */",
             format("/*\n"
-                   "* line */",
-                   getLLVMStyle()));
+                   "* line */"));
   EXPECT_EQ("/*\n"
             " * line */",
             format("/*\n"
-                   " * line */",
-                   getLLVMStyle()));
+                   " * line */"));
   EXPECT_EQ("/*\n"
             " * line */",
             format("/*\n"
-                   "  * line */",
-                   getLLVMStyle()));
+                   "  * line */"));
   EXPECT_EQ("/*\n"
             " * line */",
             format("/*\n"
-                   "   * line */",
-                   getLLVMStyle()));
+                   "   * line */"));
   EXPECT_EQ("/**\n"
             " * line */",
             format("/**\n"
-                   "* line */",
-                   getLLVMStyle()));
+                   "* line */"));
   EXPECT_EQ("/**\n"
             " * line */",
             format("/**\n"
-                   " * line */",
-                   getLLVMStyle()));
+                   " * line */"));
   EXPECT_EQ("/**\n"
             " * line */",
             format("/**\n"
-                   "  * line */",
-                   getLLVMStyle()));
+                   "  * line */"));
   EXPECT_EQ("/**\n"
             " * line */",
             format("/**\n"
-                   "   * line */",
-                   getLLVMStyle()));
+                   "   * line */"));
   EXPECT_EQ("/**\n"
             " * line */",
             format("/**\n"
-                   "    * line */",
-                   getLLVMStyle()));
+                   "    * line */"));
 
   // Align the end '*/' after a line.
   EXPECT_EQ("/*\n"
@@ -3142,64 +3130,53 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
             " */",
             format("/*\n"
                    "* line\n"
-                   "*/",
-                   getLLVMStyle()));
+                   "*/"));
   EXPECT_EQ("/*\n"
             " * line\n"
             " */",
             format("/*\n"
                    "   * line\n"
-                   "  */",
-                   getLLVMStyle()));
+                   "  */"));
   EXPECT_EQ("/*\n"
             " * line\n"
             " */",
             format("/*\n"
                    "  * line\n"
-                   "  */",
-                   getLLVMStyle()));
+                   "  */"));
 
   // Align two lines.
   EXPECT_EQ("/* line 1\n"
             " * line 2 */",
             format("/* line 1\n"
-                   " * line 2 */",
-                   getLLVMStyle()));
+                   " * line 2 */"));
   EXPECT_EQ("/* line 1\n"
             " * line 2 */",
             format("/* line 1\n"
-                   "* line 2 */",
-                   getLLVMStyle()));
+                   "* line 2 */"));
   EXPECT_EQ("/* line 1\n"
             " * line 2 */",
             format("/* line 1\n"
-                   "  * line 2 */",
-                   getLLVMStyle()));
+                   "  * line 2 */"));
   EXPECT_EQ("/* line 1\n"
             " * line 2 */",
             format("/* line 1\n"
-                   "   * line 2 */",
-                   getLLVMStyle()));
+                   "   * line 2 */"));
   EXPECT_EQ("/* line 1\n"
             " * line 2 */",
             format("/* line 1\n"
-                   "    * line 2 */",
-                   getLLVMStyle()));
+                   "    * line 2 */"));
   EXPECT_EQ("int i; /* line 1\n"
             "        * line 2 */",
             format("int i; /* line 1\n"
-                   "* line 2 */",
-                   getLLVMStyle()));
+                   "* line 2 */"));
   EXPECT_EQ("int i; /* line 1\n"
             "        * line 2 */",
             format("int i; /* line 1\n"
-                   "        * line 2 */",
-                   getLLVMStyle()));
+                   "        * line 2 */"));
   EXPECT_EQ("int i; /* line 1\n"
             "        * line 2 */",
             format("int i; /* line 1\n"
-                   "             * line 2 */",
-                   getLLVMStyle()));
+                   "             * line 2 */"));
 
   // Align several lines.
   EXPECT_EQ("/* line 1\n"
@@ -3207,15 +3184,13 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
             " * line 3 */",
             format("/* line 1\n"
                    " * line 2\n"
-                   "* line 3 */",
-                   getLLVMStyle()));
+                   "* line 3 */"));
   EXPECT_EQ("/* line 1\n"
             " * line 2\n"
             " * line 3 */",
             format("/* line 1\n"
                    "  * line 2\n"
-                   "* line 3 */",
-                   getLLVMStyle()));
+                   "* line 3 */"));
   EXPECT_EQ("/*\n"
             "** line 1\n"
             "** line 2\n"
@@ -3223,8 +3198,7 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
             format("/*\n"
                    "** line 1\n"
                    " ** line 2\n"
-                   "*/",
-                   getLLVMStyle()));
+                   "*/"));
 
   // Align with 
diff erent indent after the decorations.
   EXPECT_EQ("/*\n"
@@ -3238,8 +3212,7 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
                    "  *  line 2\n"
                    "   * line 3\n"
                    "*   line 4\n"
-                   "*/",
-                   getLLVMStyle()));
+                   "*/"));
 
   // Align empty or blank lines.
   EXPECT_EQ("/**\n"
@@ -3251,8 +3224,7 @@ TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
                    "*  \n"
                    " * \n"
                    "  *\n"
-                   "*/",
-                   getLLVMStyle()));
+                   "*/"));
 
   // Align while breaking and reflowing.
   EXPECT_EQ("/*\n"


        


More information about the cfe-commits mailing list