]> granicus.if.org Git - clang/commitdiff
clang-format: Add include sorting capabilities to sublime, emacs and
authorDaniel Jasper <djasper@google.com>
Wed, 7 Oct 2015 17:00:20 +0000 (17:00 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 7 Oct 2015 17:00:20 +0000 (17:00 +0000)
clang-format-diff.py.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249567 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-format/clang-format-diff.py
tools/clang-format/clang-format-sublime.py
tools/clang-format/clang-format.el

index 64efb83a8c19eab5d0b5d50a101440a927aa934a..9e02bb09387f87f90e70df024730f4f1538cf195 100755 (executable)
@@ -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])
index 16ff56e502c66f71c1cbeb06c49cdbd50a8fc6df..1cffcecc3946c92738ab4a9845fb6276957bc682 100644 (file)
@@ -32,7 +32,7 @@ class ClangFormatCommand(sublime_plugin.TextCommand):
     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)
index ca461444e22684186ed64aa16d10b226fce881a6..6de45de70a651e825192cbdcae3f9fc1b6d30562 100644 (file)
@@ -126,6 +126,7 @@ is no active region.  If no style is given uses `clang-format-style'."
                  nil `(,temp-buffer ,temp-file) nil
 
                  "-output-replacements-xml"
+                 "-sort-includes"
                  "-assume-filename" (or (buffer-file-name) "")
                  "-style" style
                  "-offset" (number-to-string start)