summaryrefslogtreecommitdiffstats
path: root/clang/tools/clang-format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-10-07 17:00:20 +0000
committerDaniel Jasper <djasper@google.com>2015-10-07 17:00:20 +0000
commitdb125cb326602ea45ea6fd7e2394071e9ed357ee (patch)
treec38f1941af0a02a1d4d376abbf28fb3c69d394bb /clang/tools/clang-format
parent0db335fd5e0cdce981815882b8e6730cafff11f0 (diff)
downloadbcm5719-llvm-db125cb326602ea45ea6fd7e2394071e9ed357ee.tar.gz
bcm5719-llvm-db125cb326602ea45ea6fd7e2394071e9ed357ee.zip
clang-format: Add include sorting capabilities to sublime, emacs and
clang-format-diff.py. llvm-svn: 249567
Diffstat (limited to 'clang/tools/clang-format')
-rwxr-xr-xclang/tools/clang-format/clang-format-diff.py4
-rw-r--r--clang/tools/clang-format/clang-format-sublime.py2
-rw-r--r--clang/tools/clang-format/clang-format.el1
3 files changed, 6 insertions, 1 deletions
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py
index 64efb83a8c1..9e02bb09387 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -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])
diff --git a/clang/tools/clang-format/clang-format-sublime.py b/clang/tools/clang-format/clang-format-sublime.py
index 16ff56e502c..1cffcecc394 100644
--- a/clang/tools/clang-format/clang-format-sublime.py
+++ b/clang/tools/clang-format/clang-format-sublime.py
@@ -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)
diff --git a/clang/tools/clang-format/clang-format.el b/clang/tools/clang-format/clang-format.el
index ca461444e22..6de45de70a6 100644
--- a/clang/tools/clang-format/clang-format.el
+++ b/clang/tools/clang-format/clang-format.el
@@ -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)
OpenPOWER on IntegriCloud