janosimas updated this revision to Diff 234005.
janosimas added a comment.
Herald added a subscriber: mgehre.
Herald added a project: clang.

I reviewed the code over the discussion with the `--` option,
I also changed the `-p` optin to `-strip` to avoid confusion with the 
`clang-tidy` option.

sorry for taking so long ;-)


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49864/new/

https://reviews.llvm.org/D49864

Files:
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py

Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===================================================================
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -17,9 +17,9 @@
 detect clang-tidy regressions in the lines touched by a specific patch.
 Example usage for git/svn users:
 
-  git diff -U0 HEAD^ | clang-tidy-diff.py -p1
+  git diff -U0 HEAD^ | clang-tidy-diff.py -strip 1 -- -fix -checks=-*,modernize-use-override
   svn diff --diff-cmd=diff -x-U0 | \
-      clang-tidy-diff.py -fix -checks=-*,modernize-use-override
+      clang-tidy-diff.py -- -fix -checks=-*,modernize-use-override
 
 """
 
@@ -118,12 +118,13 @@
   parser = argparse.ArgumentParser(description=
                                    'Run clang-tidy against changed files, and '
                                    'output diagnostics only for modified '
-                                   'lines.')
+                                   'lines.'
+                                   '\nclang-tidy arguments should be passed after a \'--\' .')
   parser.add_argument('-clang-tidy-binary', metavar='PATH',
                       default='clang-tidy',
                       help='path to clang-tidy binary')
-  parser.add_argument('-p', metavar='NUM', default=0,
-                      help='strip the smallest prefix containing P slashes')
+  parser.add_argument('-strip', metavar='NUM', default=0,
+                      help='strip the smallest prefix containing N slashes')
   parser.add_argument('-regex', metavar='PATTERN', default=None,
                       help='custom pattern selecting file paths to check '
                       '(case sensitive, overrides -iregex)')
@@ -135,32 +136,15 @@
                       help='number of tidy instances to be run in parallel.')
   parser.add_argument('-timeout', type=int, default=None,
                       help='timeout per each file in seconds.')
-  parser.add_argument('-fix', action='store_true', default=False,
-                      help='apply suggested fixes')
-  parser.add_argument('-checks',
-                      help='checks filter, when not specified, use clang-tidy '
-                      'default',
-                      default='')
-  parser.add_argument('-path', dest='build_path',
-                      help='Path used to read a compile command database.')
   if yaml:
     parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
                         help='Create a yaml file to store suggested fixes in, '
                         'which can be applied with clang-apply-replacements.')
-  parser.add_argument('-extra-arg', dest='extra_arg',
-                      action='append', default=[],
-                      help='Additional argument to append to the compiler '
-                      'command line.')
-  parser.add_argument('-extra-arg-before', dest='extra_arg_before',
-                      action='append', default=[],
-                      help='Additional argument to prepend to the compiler '
-                      'command line.')
-  parser.add_argument('-quiet', action='store_true', default=False,
-                      help='Run clang-tidy in quiet mode')
+
   clang_tidy_args = []
   argv = sys.argv[1:]
   if '--' in argv:
-    clang_tidy_args.extend(argv[argv.index('--'):])
+    clang_tidy_args.extend(argv[argv.index('--')+1:])
     argv = argv[:argv.index('--')]
 
   args = parser.parse_args(argv)
@@ -169,7 +153,7 @@
   filename = None
   lines_by_file = {}
   for line in sys.stdin:
-    match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.p, line)
+    match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.strip, line)
     if match:
       filename = match.group(2)
     if filename is None:
@@ -216,19 +200,6 @@
 
   # Form the common args list.
   common_clang_tidy_args = []
-  if args.fix:
-    common_clang_tidy_args.append('-fix')
-  if args.checks != '':
-    common_clang_tidy_args.append('-checks=' + args.checks)
-  if args.quiet:
-    common_clang_tidy_args.append('-quiet')
-  if args.build_path is not None:
-    common_clang_tidy_args.append('-p=%s' % args.build_path)
-  for arg in args.extra_arg:
-    common_clang_tidy_args.append('-extra-arg=%s' % arg)
-  for arg in args.extra_arg_before:
-    common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
-
   for name in lines_by_file:
     line_filter_json = json.dumps(
       [{"name": name, "lines": lines_by_file[name]}],
@@ -266,3 +237,4 @@
 
 if __name__ == '__main__':
   main()
+  
\ No newline at end of file
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D49864: [clang-tidy] Th... Jano Simas via Phabricator via cfe-commits

Reply via email to