r372444 - [clang-scan-deps] strip the --serialize-diagnostics argument
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 20 17:17:27 PDT 2019
Author: arphaman
Date: Fri Sep 20 17:17:26 2019
New Revision: 372444
URL: http://llvm.org/viewvc/llvm-project?rev=372444&view=rev
Log:
[clang-scan-deps] strip the --serialize-diagnostics argument
This ensures that clang-scan-deps won't write out diagnostics when
scanning dependencies.
Added:
cfe/trunk/test/ClangScanDeps/Inputs/strip_diag_serialize.json
cfe/trunk/test/ClangScanDeps/strip_diag_serialize.cpp
Modified:
cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h
cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp
cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
Modified: cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h?rev=372444&r1=372443&r2=372444&view=diff
==============================================================================
--- cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h (original)
+++ cfe/trunk/include/clang/Tooling/ArgumentsAdjusters.h Fri Sep 20 17:17:26 2019
@@ -43,6 +43,10 @@ ArgumentsAdjuster getClangSyntaxOnlyAdju
/// arguments.
ArgumentsAdjuster getClangStripOutputAdjuster();
+/// Gets an argument adjuster which removes command line arguments related to
+/// diagnostic serialization.
+ArgumentsAdjuster getClangStripSerializeDiagnosticAdjuster();
+
/// Gets an argument adjuster which removes dependency-file
/// related command line arguments.
ArgumentsAdjuster getClangStripDependencyFileAdjuster();
Modified: cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp?rev=372444&r1=372443&r2=372444&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp (original)
+++ cfe/trunk/lib/Tooling/ArgumentsAdjusters.cpp Fri Sep 20 17:17:26 2019
@@ -57,6 +57,22 @@ ArgumentsAdjuster getClangStripOutputAdj
};
}
+ArgumentsAdjuster getClangStripSerializeDiagnosticAdjuster() {
+ return [](const CommandLineArguments &Args, StringRef /*unused*/) {
+ CommandLineArguments AdjustedArgs;
+ for (size_t i = 0, e = Args.size(); i < e; ++i) {
+ StringRef Arg = Args[i];
+ if (Arg == "--serialize-diagnostics") {
+ // Skip the diagnostic output argument.
+ ++i;
+ continue;
+ }
+ AdjustedArgs.push_back(Args[i]);
+ }
+ return AdjustedArgs;
+ };
+}
+
ArgumentsAdjuster getClangStripDependencyFileAdjuster() {
return [](const CommandLineArguments &Args, StringRef /*unused*/) {
CommandLineArguments AdjustedArgs;
Added: cfe/trunk/test/ClangScanDeps/Inputs/strip_diag_serialize.json
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/strip_diag_serialize.json?rev=372444&view=auto
==============================================================================
--- cfe/trunk/test/ClangScanDeps/Inputs/strip_diag_serialize.json (added)
+++ cfe/trunk/test/ClangScanDeps/Inputs/strip_diag_serialize.json Fri Sep 20 17:17:26 2019
@@ -0,0 +1,7 @@
+[
+{
+ "directory": "DIR",
+ "command": "clang -E -fsyntax-only DIR/strip_diag_serialize_input.cpp --serialize-diagnostics /does/not/exist",
+ "file": "DIR/strip_diag_serialize_input.cpp"
+}
+]
Added: cfe/trunk/test/ClangScanDeps/strip_diag_serialize.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/strip_diag_serialize.cpp?rev=372444&view=auto
==============================================================================
--- cfe/trunk/test/ClangScanDeps/strip_diag_serialize.cpp (added)
+++ cfe/trunk/test/ClangScanDeps/strip_diag_serialize.cpp Fri Sep 20 17:17:26 2019
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/strip_diag_serialize_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/strip_diag_serialize.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb 2>&1 | FileCheck %s
+// CHECK-NOT: unable to open file
+// CHECK: strip_diag_serialize_input.cpp
+
+#warning "diagnostic"
Modified: cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp?rev=372444&r1=372443&r2=372444&view=diff
==============================================================================
--- cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp (original)
+++ cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp Fri Sep 20 17:17:26 2019
@@ -266,6 +266,8 @@ int main(int argc, const char **argv) {
AdjustedArgs.push_back("-Wno-error");
return AdjustedArgs;
});
+ AdjustingCompilations->appendArgumentsAdjuster(
+ tooling::getClangStripSerializeDiagnosticAdjuster());
SharedStream Errs(llvm::errs());
// Print out the dependency results to STDOUT by default.
More information about the cfe-commits
mailing list