[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 4 16:36:56 PST 2017
ehsan created this revision.
ehsan added reviewers: bkramer, alexfh, klimek.
ehsan added a subscriber: cfe-commits.
Herald added a subscriber: JDevlieghere.
These flags allow specifying extra arguments to the tool's command
line which don't appear in the compilation database.
https://reviews.llvm.org/D28334
Files:
clang-tidy/tool/run-clang-tidy.py
Index: clang-tidy/tool/run-clang-tidy.py
===================================================================
--- clang-tidy/tool/run-clang-tidy.py
+++ 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[0])
+ for arg in extra_arg_before:
+ start.append('-extra-arg-before=%s' % arg[0])
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',
+ nargs=1, action='append', default=[],
+ help='Additional argument to append to the compiler '
+ 'command line.')
+ parser.add_argument('-extra-arg-before', dest='extra_arg_before',
+ nargs=1, 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.83165.patch
Type: text/x-patch
Size: 2083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170105/6e32b641/attachment.bin>
More information about the cfe-commits
mailing list