diff options
| author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2017-02-17 19:31:43 +0000 |
|---|---|---|
| committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2017-02-17 19:31:43 +0000 |
| commit | fae3ac3e9b1b0ed02936d101c42a0f145b001f91 (patch) | |
| tree | 00a1dad155a428aba406e9e963ec557571e8b754 /clang-tools-extra | |
| parent | 7acbeaf1bccbfb3f8ef55960d0049dbd0399fafd (diff) | |
| download | bcm5719-llvm-fae3ac3e9b1b0ed02936d101c42a0f145b001f91.tar.gz bcm5719-llvm-fae3ac3e9b1b0ed02936d101c42a0f145b001f91.zip | |
[clang-tidy] Add -path option to clang-tidy-diff.py
Summary:
This flag allows specifying a custom path for the compilation
database. Unfortunately we can't use the -p flag like other
clang-tidy tools because it's already taken.
Reviewers: alexfh
Subscribers: JDevlieghere, cfe-commits
Differential Revision: https://reviews.llvm.org/D29806
llvm-svn: 295482
Diffstat (limited to 'clang-tools-extra')
| -rwxr-xr-x | clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 4 | ||||
| -rw-r--r-- | clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py index fa6f5284d91..f2c15e5e559 100755 --- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py +++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py @@ -55,6 +55,8 @@ def main(): help='checks filter, when not specified, use clang-tidy ' 'default', default='') + parser.add_argument('-path', 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 ' @@ -124,6 +126,8 @@ def main(): command.append('-checks=' + quote + args.checks + quote) if args.quiet: command.append('-quiet') + if args.build_path is not None: + command.append('-p=%s' % args.build_path) command.extend(lines_by_file.keys()) for arg in args.extra_arg: command.append('-extra-arg=%s' % arg) diff --git a/clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp b/clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp index ce4aa1259f0..186c7dd4322 100644 --- a/clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp +++ b/clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp @@ -2,6 +2,9 @@ // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | FileCheck -check-prefix=CHECK-SANITY %s // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck -check-prefix=CHECK-QUIET %s +// RUN: mkdir -p %T/compilation-database-test/ +// RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 %t.cpp", "file": "%t.cpp"}]' > %T/compilation-database-test/compile_commands.json +// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | FileCheck -check-prefix=CHECK %s struct A { virtual void f() {} virtual void g() {} |

