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 @@ -128,10 +128,21 @@ 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 @@ 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]