r249567 - clang-format: Add include sorting capabilities to sublime, emacs and

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 7 10:00:20 PDT 2015


Author: djasper
Date: Wed Oct  7 12:00:20 2015
New Revision: 249567

URL: http://llvm.org/viewvc/llvm-project?rev=249567&view=rev
Log:
clang-format: Add include sorting capabilities to sublime, emacs and
clang-format-diff.py.

Modified:
    cfe/trunk/tools/clang-format/clang-format-diff.py
    cfe/trunk/tools/clang-format/clang-format-sublime.py
    cfe/trunk/tools/clang-format/clang-format.el

Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=249567&r1=249566&r2=249567&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Wed Oct  7 12:00:20 2015
@@ -52,6 +52,8 @@ def main():
                       r'|protodevel|java)',
                       help='custom pattern selecting file paths to reformat '
                       '(case insensitive, overridden by -regex)')
+  parser.add_argument('-sort-includes', action='store_true', default=False,
+                      help='let clang-format sort include blocks')
   parser.add_argument('-v', '--verbose', action='store_true',
                       help='be more verbose, ineffective without -i')
   parser.add_argument(
@@ -96,6 +98,8 @@ def main():
     command = [binary, filename]
     if args.i:
       command.append('-i')
+    if args.sort_includes:
+      command.append('-sort-includes')
     command.extend(lines)
     if args.style:
       command.extend(['-style', args.style])

Modified: cfe/trunk/tools/clang-format/clang-format-sublime.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-sublime.py?rev=249567&r1=249566&r2=249567&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format-sublime.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-sublime.py Wed Oct  7 12:00:20 2015
@@ -32,7 +32,7 @@ class ClangFormatCommand(sublime_plugin.
     if encoding == 'Undefined':
       encoding = 'utf-8'
     regions = []
-    command = [binary, '-style', style]
+    command = [binary, '-sort-includes', '-style', style]
     for region in self.view.sel():
       regions.append(region)
       region_offset = min(region.a, region.b)

Modified: cfe/trunk/tools/clang-format/clang-format.el
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.el?rev=249567&r1=249566&r2=249567&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.el (original)
+++ cfe/trunk/tools/clang-format/clang-format.el Wed Oct  7 12:00:20 2015
@@ -126,6 +126,7 @@ is no active region.  If no style is giv
                  nil `(,temp-buffer ,temp-file) nil
 
                  "-output-replacements-xml"
+                 "-sort-includes"
                  "-assume-filename" (or (buffer-file-name) "")
                  "-style" style
                  "-offset" (number-to-string start)




More information about the cfe-commits mailing list