[PATCH] D28334: [clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py

Ehsan Akhgari via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 18 10:00:39 PST 2017


This revision was automatically updated to reflect the committed changes.
ehsan marked an inline comment as done.
Closed by commit rL292415: [clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py (authored by ehsan).

Changed prior to commit:
  https://reviews.llvm.org/D28334?vs=83165&id=84854#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28334

Files:
  clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
===================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
@@ -59,7 +59,7 @@
 
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
-                        header_filter):
+                        header_filter, extra_arg, extra_arg_before):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if header_filter is not None:
@@ -76,6 +76,10 @@
     (handle, name) = tempfile.mkstemp(suffix='.yaml', dir=tmpdir)
     os.close(handle)
     start.append(name)
+  for arg in extra_arg:
+      start.append('-extra-arg=%s' % arg)
+  for arg in extra_arg_before:
+      start.append('-extra-arg-before=%s' % arg)
   start.append('-p=' + build_path)
   start.append(f)
   return start
@@ -96,7 +100,8 @@
   while True:
     name = queue.get()
     invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
-                                     tmpdir, build_path, args.header_filter)
+                                     tmpdir, build_path, args.header_filter,
+                                     args.extra_arg, args.extra_arg_before)
     sys.stdout.write(' '.join(invocation) + '\n')
     subprocess.call(invocation)
     queue.task_done()
@@ -130,6 +135,14 @@
                       'after applying fixes')
   parser.add_argument('-p', dest='build_path',
                       help='Path used to read a compile command database.')
+  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.')
   args = parser.parse_args()
 
   db_path = 'compile_commands.json'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28334.84854.patch
Type: text/x-patch
Size: 2131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170118/525819d5/attachment.bin>


More information about the cfe-commits mailing list