aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2025-04-30 00:09:29 -0700
committerOwen Pan <owenpiano@gmail.com>2025-04-30 00:12:41 -0700
commit7752e0a10b25da2f2eadbed10606bd5454dbca05 (patch)
tree298332e72d270e10c30e6cd7e44a296f61a77add /clang/unittests
parent38cb7d5e7591cdfb39d1030480920ec1ce4873c6 (diff)
downloadllvm-7752e0a10b25da2f2eadbed10606bd5454dbca05.zip
llvm-7752e0a10b25da2f2eadbed10606bd5454dbca05.tar.gz
llvm-7752e0a10b25da2f2eadbed10606bd5454dbca05.tar.bz2
Revert "[clang-format] Add OneLineFormatOffRegex option (#137577)"
This reverts commit b8bb1ccb4f9126d1bc9817be24e17f186a75a08b which triggered an assertion failure in CodeGenTest.TestNonAlterTest.
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/Format/ConfigParseTest.cpp1
-rw-r--r--clang/unittests/Format/FormatTest.cpp99
2 files changed, 0 insertions, 100 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index f7ab554..2b08b79 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -295,7 +295,6 @@ TEST(ConfigParseTest, ParsesConfiguration) {
FormatStyle Style = {};
Style.Language = FormatStyle::LK_Cpp;
CHECK_PARSE("CommentPragmas: '// abc$'", CommentPragmas, "// abc$");
- CHECK_PARSE("OneLineFormatOffRegex: // ab$", OneLineFormatOffRegex, "// ab$");
Style.QualifierAlignment = FormatStyle::QAS_Right;
CHECK_PARSE("QualifierAlignment: Leave", QualifierAlignment,
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index c4fcc55..333d40d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -24954,105 +24954,6 @@ TEST_F(FormatTest, DisableRegions) {
"// clang-format on");
}
-TEST_F(FormatTest, OneLineFormatOffRegex) {
- auto Style = getLLVMStyle();
- Style.OneLineFormatOffRegex = "// format off$";
-
- verifyFormat(" // format off\n"
- " int i ;\n"
- "int j;",
- " // format off\n"
- " int i ;\n"
- " int j ;",
- Style);
- verifyFormat("// format off?\n"
- "int i;",
- " // format off?\n"
- " int i ;",
- Style);
- verifyFormat("f(\"// format off\");", " f(\"// format off\") ;", Style);
-
- verifyFormat("int i;\n"
- " // format off\n"
- " int j ;\n"
- "int k;",
- " int i ;\n"
- " // format off\n"
- " int j ;\n"
- " int k ;",
- Style);
-
- verifyFormat(" // format off\n"
- "\n"
- "int i;",
- " // format off\n"
- " \n"
- " int i ;",
- Style);
-
- verifyFormat("int i;\n"
- " int j ; // format off\n"
- "int k;",
- " int i ;\n"
- " int j ; // format off\n"
- " int k ;",
- Style);
-
- verifyFormat("// clang-format off\n"
- " int i ;\n"
- " int j ; // format off\n"
- " int k ;\n"
- "// clang-format on\n"
- "f();",
- " // clang-format off\n"
- " int i ;\n"
- " int j ; // format off\n"
- " int k ;\n"
- " // clang-format on\n"
- " f() ;",
- Style);
-
- Style.OneLineFormatOffRegex = "^/\\* format off \\*/";
- verifyFormat("int i;\n"
- " /* format off */ int j ;\n"
- "int k;",
- " int i ;\n"
- " /* format off */ int j ;\n"
- " int k ;",
- Style);
- verifyFormat("f(\"/* format off */\");", " f(\"/* format off */\") ;", Style);
-
- Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
- verifyFormat("#define A \\\n"
- " do { \\\n"
- " /* format off */\\\n"
- " f() ; \\\n"
- " g(); \\\n"
- " } while (0)",
- "# define A\\\n"
- " do{ \\\n"
- " /* format off */\\\n"
- " f() ; \\\n"
- " g() ;\\\n"
- " } while (0 )",
- Style);
-
- Style.ColumnLimit = 50;
- Style.OneLineFormatOffRegex = "^LogErrorPrint$";
- verifyFormat(" myproject::LogErrorPrint(logger, \"Don't split me!\");\n"
- "myproject::MyLogErrorPrinter(myLogger,\n"
- " \"Split me!\");",
- " myproject::LogErrorPrint(logger, \"Don't split me!\");\n"
- " myproject::MyLogErrorPrinter(myLogger, \"Split me!\");",
- Style);
-
- Style.OneLineFormatOffRegex = "//(< clang-format off| NO_TRANSLATION)$";
- verifyNoChange(
- " int i ; //< clang-format off\n"
- " msg = sprintf(\"Long string with placeholders.\"); // NO_TRANSLATION",
- Style);
-}
-
TEST_F(FormatTest, DoNotCrashOnInvalidInput) {
format("? ) =");
verifyNoCrash("#define a\\\n /**/}");