r250675 - clang-format: Extend main header include sorting heuristic to Objective-C files.

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 18 18:36:09 PDT 2015


Author: nico
Date: Sun Oct 18 20:36:09 2015
New Revision: 250675

URL: http://llvm.org/viewvc/llvm-project?rev=250675&view=rev
Log:
clang-format: Extend main header include sorting heuristic to Objective-C files.

Modified:
    cfe/trunk/lib/Format/Format.cpp
    cfe/trunk/unittests/Format/SortIncludesTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=250675&r1=250674&r2=250675&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Sun Oct 18 20:36:09 2015
@@ -1747,7 +1747,9 @@ tooling::Replacements sortIncludes(const
                            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;

Modified: cfe/trunk/unittests/Format/SortIncludesTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortIncludesTest.cpp?rev=250675&r1=250674&r2=250675&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp (original)
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp Sun Oct 18 20:36:09 2015
@@ -122,6 +122,13 @@ TEST_F(SortIncludesTest, LeavesMainHeade
             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"




More information about the cfe-commits mailing list