diff options
author | Alp Toker <alp@nuanti.com> | 2013-12-10 13:51:53 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2013-12-10 13:51:53 +0000 |
commit | 8c7cbdf53ad0d0dc596dea63be31520a2d7e1819 (patch) | |
tree | cdb2c2eb8779cdd22b3686ff6e888d61a50bbaa8 /clang/tools/clang-format/clang-format-diff.py | |
parent | ac85179219ca168322fe25e5ed4ce174e2f741a4 (diff) | |
download | bcm5719-llvm-8c7cbdf53ad0d0dc596dea63be31520a2d7e1819.tar.gz bcm5719-llvm-8c7cbdf53ad0d0dc596dea63be31520a2d7e1819.zip |
clang-format-diff.py: Support -regex filter and more filename extensions
Add support for more filename extensions based on the list in the clang
plus JavaScript.
Also adds a -regex option so users can override defaults if they have unusual
file extensions or want to format everything in the diff.
Keeping with tradition the flag is modelled on Unix conventions, this time
matching the semantics of find(1).
llvm-svn: 196917
Diffstat (limited to 'clang/tools/clang-format/clang-format-diff.py')
-rwxr-xr-x | clang/tools/clang-format/clang-format-diff.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py index a62cae8ad51..f8fceeb4fc0 100755 --- a/clang/tools/clang-format/clang-format-diff.py +++ b/clang/tools/clang-format/clang-format-diff.py @@ -41,8 +41,11 @@ def main(): 'introduced.') parser.add_argument('-i', action='store_true', default=False, help='apply edits to files instead of displaying a diff') - parser.add_argument('-p', default=0, + parser.add_argument('-p', metavar='NUM', default=0, help='strip the smallest prefix containing P slashes') + parser.add_argument('-regex', metavar='PATTERN', default= + r'.*\.(cpp|cc|CPP|C|c\+\+|cxx|c|h|hpp|m|mm|inc|js)', + help='custom pattern selecting file paths to reformat') parser.add_argument( '-style', help= @@ -59,9 +62,7 @@ def main(): if filename == None: continue - # FIXME: Add other types containing C++/ObjC code. - if not (filename.endswith(".cpp") or filename.endswith(".cc") or - filename.endswith(".h")): + if not re.match(args.regex, filename): continue match = re.search('^@@.*\+(\d+)(,(\d+))?', line) |