clang-format: Add special comments to disable formatting.
With this patch:
int ThisWillBeFormatted;
// clang-format off
int ThisWontBeFormatted;
// clang-format on
int Formatted;
This is for regions where a significantly nicer code layout can be found
knowing the content of the code.
This fixes llvm.org/PR20463.
llvm-svn: 214966
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 5c526c1..318f5b4 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9133,5 +9133,18 @@
"int i;\n"));
}
+TEST_F(FormatTest, DisableRegions) {
+ EXPECT_EQ("int i;\n"
+ "// clang-format off\n"
+ " int j;\n"
+ "// clang-format on\n"
+ "int k;",
+ format(" int i;\n"
+ " // clang-format off\n"
+ " int j;\n"
+ " // clang-format on\n"
+ " int k;"));
+}
+
} // end namespace tooling
} // end namespace clang