]> granicus.if.org Git - clang/commitdiff
clang-format: Extend main header include sorting heuristic to Objective-C files.
authorNico Weber <nicolasweber@gmx.de>
Mon, 19 Oct 2015 01:36:09 +0000 (01:36 +0000)
committerNico Weber <nicolasweber@gmx.de>
Mon, 19 Oct 2015 01:36:09 +0000 (01:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250675 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp
unittests/Format/SortIncludesTest.cpp

index 674af7ac5312dfd9d3c4e1e1e9184e4486fa05d8..2595a666699c51c3818a5ab58b8508fd02a3b4c8 100644 (file)
@@ -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;
index 8908eb92a562063082709258c3511cc2e5999244..36c8351810e36467c1de405d5e19098fc9b4e95f 100644 (file)
@@ -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"