summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
diff options
context:
space:
mode:
authorGuillaume Papin <guillaume.papin@epitech.eu>2015-09-28 17:53:04 +0000
committerGuillaume Papin <guillaume.papin@epitech.eu>2015-09-28 17:53:04 +0000
commit68b591079a87c83e91d5963c4d3f610879fe4fb1 (patch)
treedd35b328c9aed690931428f7a6f51cd4d3ab3eff /clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
parent36c42b592d4f45bdd885382ba9818147125463e4 (diff)
downloadbcm5719-llvm-68b591079a87c83e91d5963c4d3f610879fe4fb1.tar.gz
bcm5719-llvm-68b591079a87c83e91d5963c4d3f610879fe4fb1.zip
[clang-tidy] add option to specify build path
Summary: compile_commands.json is usually generated in the build directory. Projects like LLVM/Clang enforce out-of-source builds. This option allow allow such projects to work out of the box, without moving the compilation database manually. The naming of the option is similar to the one use by other tools: clang-{check,modernize,query,rename,tidy} -p=<build_path> <...> Reviewers: alexfh Differential Revision: http://reviews.llvm.org/D13199 llvm-svn: 248723
Diffstat (limited to 'clang-tools-extra/clang-tidy/tool/run-clang-tidy.py')
-rwxr-xr-xclang-tools-extra/clang-tidy/tool/run-clang-tidy.py15
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]
OpenPOWER on IntegriCloud