diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/tool/run-clang-tidy.py')
-rwxr-xr-x | clang-tools-extra/clang-tidy/tool/run-clang-tidy.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py index 73c5140a180..e4dd3da447e 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -128,10 +128,21 @@ def main(): parser.add_argument('-fix', action='store_true', help='apply fix-its') parser.add_argument('-format', action='store_true', help='Reformat code ' 'after applying fixes') + parser.add_argument('-p', dest='build_path', + help='Path used to read a compile command database.') args = parser.parse_args() + db_path = 'compile_commands.json' + + if args.build_path is not None: + build_path = args.build_path + else: + # Find our database + build_path = find_compilation_database(db_path) + try: invocation = [args.clang_tidy_binary, '-list-checks'] + invocation.append('-p=' + build_path) if args.checks: invocation.append('-checks=' + args.checks) invocation.append('-') @@ -140,10 +151,6 @@ def main(): print >>sys.stderr, "Unable to run clang-tidy." sys.exit(1) - # Find our database. - db_path = 'compile_commands.json' - build_path = find_compilation_database(db_path) - # Load the database and extract all files. database = json.load(open(os.path.join(build_path, db_path))) files = [entry['file'] for entry in database] |