diff options
author | Haojian Wu <hokein@google.com> | 2016-02-26 09:19:33 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2016-02-26 09:19:33 +0000 |
commit | f7692a27923bbeb7cfdeb26909c2a3f0894bc132 (patch) | |
tree | 99df56fc5481b00f5cd38566f81b0fac1c22156e /clang-tools-extra/test/clang-tidy/clang-tidy-run-with-database.cpp | |
parent | 4eba0154fb19081462e67666ffaa815036ffe7c5 (diff) | |
download | bcm5719-llvm-f7692a27923bbeb7cfdeb26909c2a3f0894bc132.tar.gz bcm5719-llvm-f7692a27923bbeb7cfdeb26909c2a3f0894bc132.zip |
[clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.
Summary:
The clang-tidy will trigger an assertion if it's not in the building directory.
TEST:
cd <llvm-repo>/
./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
The crash issue is gone after applying this patch.
Fixes PR24834, PR26241
Reviewers: bkramer, alexfh
Subscribers: rizsotto.mailinglist, cfe-commits
Differential Revision: http://reviews.llvm.org/D17335
llvm-svn: 261991
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/clang-tidy-run-with-database.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/clang-tidy-run-with-database.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/clang-tidy-run-with-database.cpp b/clang-tools-extra/test/clang-tidy/clang-tidy-run-with-database.cpp new file mode 100644 index 00000000000..7304f0645ed --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/clang-tidy-run-with-database.cpp @@ -0,0 +1,24 @@ +// REQUIRES: shell +// RUN: mkdir -p %T/compilation-database-test/include +// RUN: mkdir -p %T/compilation-database-test/a +// RUN: mkdir -p %T/compilation-database-test/b +// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp +// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp +// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp +// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp +// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h +// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp +// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json +// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.* +// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix +// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1 +// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2 +// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3 +// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4 +// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX5 + +// CHECK-FIX1: int *AA = nullptr; +// CHECK-FIX2: int *AB = nullptr; +// CHECK-FIX3: int *BB = nullptr; +// CHECK-FIX4: int *BC = nullptr; +// CHECK-FIX5: int *HP = nullptr; |