summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/Format.cpp4
-rw-r--r--clang/unittests/Format/SortIncludesTest.cpp7
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 674af7ac531..2595a666699 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1747,7 +1747,9 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
FileName.endswith(".cc") ||
FileName.endswith(".cpp")||
FileName.endswith(".c++")||
- FileName.endswith(".cxx");
+ FileName.endswith(".cxx") ||
+ FileName.endswith(".m")||
+ FileName.endswith(".mm");
// Create pre-compiled regular expressions for the #include categories.
SmallVector<llvm::Regex, 4> CategoryRegexs;
diff --git a/clang/unittests/Format/SortIncludesTest.cpp b/clang/unittests/Format/SortIncludesTest.cpp
index 8908eb92a56..36c8351810e 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -122,6 +122,13 @@ TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
sort("#include \"llvm/a.h\"\n"
"#include \"c.h\"\n"
"#include \"b.h\"\n"));
+ EXPECT_EQ("#include \"llvm/a.h\"\n"
+ "#include \"b.h\"\n"
+ "#include \"c.h\"\n",
+ sort("#include \"llvm/a.h\"\n"
+ "#include \"c.h\"\n"
+ "#include \"b.h\"\n",
+ "input.mm"));
// Don't do this in headers.
EXPECT_EQ("#include \"b.h\"\n"
OpenPOWER on IntegriCloud