[PATCH] D69090: [Try 2] Include sanitize blacklist and other extra deps as part of scan-deps output
Kousik Kumar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 17 00:30:20 PDT 2019
kousikk created this revision.
kousikk added reviewers: arphaman, dexonsmith, Bigcheese, jkorous.
kousikk added a project: clang.
kousikk edited the summary of this revision.
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.
This is a retry of https://reviews.llvm.org/rC375074. From the build-bot failure on
Windows, it seemed like somehow the blacklist file was already added as a dependency.
So the extra change in this patch is that I add deps to a set in clang-scan-deps
to eliminate duplicates and print in sorted order. Having a set achieves two purposes:
1. Prints out the dependencies in sorted order
2. Eliminates duplicates
Windows bot failure: http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/15956/steps/ninja%20check%202/logs/stdio
An alternative fix to the test would have been to check only for the presence of
blacklsit file, but I didn't prefer it since explicit testing of all expected outputs
is better (and in this case has led us to capture duplicate outputs).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69090
Files:
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/test/ClangScanDeps/Inputs/non-header-dependency.json
clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt
clang/test/ClangScanDeps/non-header-dependency.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp
Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===================================================================
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -17,6 +17,7 @@
#include "llvm/Support/Signals.h"
#include "llvm/Support/Threading.h"
#include <mutex>
+#include <set>
#include <thread>
using namespace clang;
@@ -66,7 +67,7 @@
StringRef File) override {
if (!this->Opts)
this->Opts = std::make_unique<DependencyOutputOptions>(Opts);
- Dependencies.push_back(File);
+ Dependencies.insert(File);
}
void printDependencies(std::string &S) {
@@ -76,7 +77,7 @@
class DependencyPrinter : public DependencyFileGenerator {
public:
DependencyPrinter(DependencyOutputOptions &Opts,
- ArrayRef<std::string> Dependencies)
+ std::set<std::string> &Dependencies)
: DependencyFileGenerator(Opts) {
for (const auto &Dep : Dependencies)
addDependency(Dep);
@@ -94,7 +95,7 @@
private:
std::unique_ptr<DependencyOutputOptions> Opts;
- std::vector<std::string> Dependencies;
+ std::set<std::string> Dependencies;
};
DependencyPrinterConsumer Consumer;
Index: clang/test/ClangScanDeps/non-header-dependency.cpp
===================================================================
--- /dev/null
+++ 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
Index: clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt
===================================================================
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/sanitize-blacklist.txt
@@ -0,0 +1 @@
+fun:*
Index: clang/test/ClangScanDeps/Inputs/non-header-dependency.json
===================================================================
--- /dev/null
+++ 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"
+ }
+]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -36,6 +36,8 @@
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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69090.225367.patch
Type: text/x-patch
Size: 3315 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191017/00f8ff8b/attachment-0001.bin>
More information about the cfe-commits
mailing list