From 962ca076e51c25a7a08f4e0d329c65328a635bdb Mon Sep 17 00:00:00 2001 From: Kousik Kumar Date: Thu, 17 Oct 2019 02:14:44 +0000 Subject: [PATCH] Include sanitize blacklist and other extra deps as part of scan-deps output Summary: Clang's -M mode includes these extra dependencies in its output and clang-scan-deps should have equivalent behavior, so adding these extradeps to output just like how its being done for ".d" file generation mode. Reviewers: arphaman, dexonsmith, Bigcheese, jkorous Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69017 llvm-svn: 375074 --- .../DependencyScanningWorker.cpp | 2 ++ .../Inputs/non-header-dependency.json | 7 +++++++ .../ClangScanDeps/Inputs/sanitize-blacklist.txt | 1 + clang/test/ClangScanDeps/non-header-dependency.cpp | 14 ++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 clang/test/ClangScanDeps/Inputs/non-header-dependency.json create mode 100644 clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt create mode 100644 clang/test/ClangScanDeps/non-header-dependency.cpp diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp index f382c202f8c2..70c8b5a082c0 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -36,6 +36,8 @@ public: llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true); C.handleFileDependency(*Opts, CanonPath); } + for (const auto& ExtraDep : Opts->ExtraDeps) + C.handleFileDependency(*Opts, ExtraDep); } private: diff --git a/clang/test/ClangScanDeps/Inputs/non-header-dependency.json b/clang/test/ClangScanDeps/Inputs/non-header-dependency.json new file mode 100644 index 000000000000..65ffa2c5ee67 --- /dev/null +++ b/clang/test/ClangScanDeps/Inputs/non-header-dependency.json @@ -0,0 +1,7 @@ +[ + { + "directory": "DIR", + "command": "clang -E DIR/non-header-dependency_input.cpp -fsanitize=bounds -fsanitize-blacklist=DIR/Inputs/sanitize-blacklist.txt", + "file": "DIR/non-header-dependency_input.cpp" + } +] diff --git a/clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt b/clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt new file mode 100644 index 000000000000..67375d823d54 --- /dev/null +++ b/clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt @@ -0,0 +1 @@ +fun:* diff --git a/clang/test/ClangScanDeps/non-header-dependency.cpp b/clang/test/ClangScanDeps/non-header-dependency.cpp new file mode 100644 index 000000000000..a43826375d3a --- /dev/null +++ b/clang/test/ClangScanDeps/non-header-dependency.cpp @@ -0,0 +1,14 @@ +// RUN: rm -rf %t.dir +// RUN: rm -rf %t.cdb +// RUN: mkdir -p %t.dir +// RUN: cp %s %t.dir/non-header-dependency_input.cpp +// RUN: mkdir %t.dir/Inputs +// RUN: cp %S/Inputs/sanitize-blacklist.txt %t.dir/Inputs/sanitize-blacklist.txt +// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/non-header-dependency.json > %t.cdb +// +// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s + +#define FOO "foo" + +// CHECK: Inputs{{/|\\}}sanitize-blacklist.txt +// CHECK-NEXT: non-header-dependency_input.cpp