summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/SortIncludesTest.cpp
diff options
context:
space:
mode:
authorPaul Hoad <mydeveloperday@gmail.com>2019-03-02 09:08:51 +0000
committerPaul Hoad <mydeveloperday@gmail.com>2019-03-02 09:08:51 +0000
commit9b468c0b1e3f6b2df84e0891263488bd61456eec (patch)
tree4ad73b978a876cd8e7b332b6b8288788a435d46e /clang/unittests/Format/SortIncludesTest.cpp
parent23b1dfe675cb026e746d85d648b2ecdf07067eb7 (diff)
downloadbcm5719-llvm-9b468c0b1e3f6b2df84e0891263488bd61456eec.tar.gz
bcm5719-llvm-9b468c0b1e3f6b2df84e0891263488bd61456eec.zip
[clang-format] clang-format off/on not respected when using C Style comments
Summary: If the clang-format on/off is in a /* comment */ then the sorting of headers is not ignored PR40901 - https://bugs.llvm.org/show_bug.cgi?id=40901 Reviewers: djasper, klimek, JonasToth, krasimir, alexfh Reviewed By: alexfh Subscribers: alexfh, cfe-commits, llvm-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D58819 llvm-svn: 355266
Diffstat (limited to 'clang/unittests/Format/SortIncludesTest.cpp')
-rw-r--r--clang/unittests/Format/SortIncludesTest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/clang/unittests/Format/SortIncludesTest.cpp b/clang/unittests/Format/SortIncludesTest.cpp
index 3f49ace75f7..75f4156f3d8 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -117,6 +117,43 @@ TEST_F(SortIncludesTest, SupportClangFormatOff) {
"// clang-format on\n"));
}
+TEST_F(SortIncludesTest, SupportClangFormatOffCStyle) {
+ EXPECT_EQ("#include <a>\n"
+ "#include <b>\n"
+ "#include <c>\n"
+ "/* clang-format off */\n"
+ "#include <b>\n"
+ "#include <a>\n"
+ "#include <c>\n"
+ "/* clang-format on */\n",
+ sort("#include <b>\n"
+ "#include <a>\n"
+ "#include <c>\n"
+ "/* clang-format off */\n"
+ "#include <b>\n"
+ "#include <a>\n"
+ "#include <c>\n"
+ "/* clang-format on */\n"));
+
+ // Not really turning it off
+ EXPECT_EQ("#include <a>\n"
+ "#include <b>\n"
+ "#include <c>\n"
+ "/* clang-format offically */\n"
+ "#include <a>\n"
+ "#include <b>\n"
+ "#include <c>\n"
+ "/* clang-format onwards */\n",
+ sort("#include <b>\n"
+ "#include <a>\n"
+ "#include <c>\n"
+ "/* clang-format offically */\n"
+ "#include <b>\n"
+ "#include <a>\n"
+ "#include <c>\n"
+ "/* clang-format onwards */\n"));
+}
+
TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
FmtStyle.SortIncludes = false;
EXPECT_EQ("#include \"a.h\"\n"
OpenPOWER on IntegriCloud