Index: clang/include/clang/Driver/SanitizerArgs.h =================================================================== --- clang/include/clang/Driver/SanitizerArgs.h +++ clang/include/clang/Driver/SanitizerArgs.h @@ -26,7 +26,6 @@ SanitizerSet TrapSanitizers; std::vector BlacklistFiles; - std::vector ExtraDeps; int CoverageFeatures = 0; int MsanTrackOrigins = 0; bool MsanUseAfterDtor = true; Index: clang/lib/Driver/SanitizerArgs.cpp =================================================================== --- clang/lib/Driver/SanitizerArgs.cpp +++ clang/lib/Driver/SanitizerArgs.cpp @@ -565,14 +565,12 @@ std::string BLPath = Arg->getValue(); if (llvm::sys::fs::exists(BLPath)) { BlacklistFiles.push_back(BLPath); - ExtraDeps.push_back(BLPath); } else { D.Diag(clang::diag::err_drv_no_such_file) << BLPath; } } else if (Arg->getOption().matches(options::OPT_fno_sanitize_blacklist)) { Arg->claim(); BlacklistFiles.clear(); - ExtraDeps.clear(); } } // Validate blacklists format. @@ -957,11 +955,6 @@ BlacklistOpt += BLPath; CmdArgs.push_back(Args.MakeArgString(BlacklistOpt)); } - for (const auto &Dep : ExtraDeps) { - SmallString<64> ExtraDepOpt("-fdepfile-entry="); - ExtraDepOpt += Dep; - CmdArgs.push_back(Args.MakeArgString(ExtraDepOpt)); - } if (MsanTrackOrigins) CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-track-origins=" + Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -1441,7 +1441,19 @@ // Add sanitizer blacklists as extra dependencies. // They won't be discovered by the regular preprocessor, so // we let make / ninja to know about this implicit dependency. - Opts.ExtraDeps = Args.getAllArgValues(OPT_fdepfile_entry); + if (!Args.hasArg(OPT_fno_sanitize_blacklist)) { + for (const auto *A : Args.filtered(OPT_fsanitize_blacklist)) { + StringRef Val = A->getValue(); + if (Val.find('=') == StringRef::npos) + Opts.ExtraDeps.push_back(Val); + } + } + + // Propagate the extra dependencies. + for (const auto *A : Args.filtered(OPT_fdepfile_entry)) { + Opts.ExtraDeps.push_back(A->getValue()); + } + // Only the -fmodule-file= form. for (const auto *A : Args.filtered(OPT_fmodule_file)) { StringRef Val = A->getValue(); Index: clang/test/ClangScanDeps/Inputs/sanitizer_blacklist_cdb.json =================================================================== --- /dev/null +++ clang/test/ClangScanDeps/Inputs/sanitizer_blacklist_cdb.json @@ -0,0 +1,7 @@ +[ +{ + "directory": "DIR", + "command": "clang -fsanitize=address -fsanitize-blacklist=DIR/black.list DIR/sanitizer_blacklist_input.cpp", + "file": "DIR/sanitizer_blacklist_input.cpp" +} +] Index: clang/test/ClangScanDeps/sanitizer_blacklist.cpp =================================================================== --- /dev/null +++ clang/test/ClangScanDeps/sanitizer_blacklist.cpp @@ -0,0 +1,12 @@ +// RUN: rm -rf %t.dir +// RUN: rm -rf %t.cdb +// RUN: mkdir -p %t.dir +// RUN: cp %s %t.dir/sanitizer_blacklist_input.cpp +// RUN: echo "fun:foo" > %t.dir/black.list +// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/sanitizer_blacklist_cdb.json > %t.cdb +// RUN: fail please +// +// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-minimized-sources | FileCheck %s +// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess | FileCheck %s +// +// CHECK: black.list Index: clang/test/Driver/fsanitize-blacklist.c =================================================================== --- clang/test/Driver/fsanitize-blacklist.c +++ clang/test/Driver/fsanitize-blacklist.c @@ -16,10 +16,6 @@ // RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST // CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.good" "-fsanitize-blacklist={{.*}}.second -// Now, check for -fdepfile-entry flags. -// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST2 -// CHECK-BLACKLIST2: -fdepfile-entry={{.*}}.good" "-fdepfile-entry={{.*}}.second - // Check that the default blacklist is not added as an extra dependency. // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST-ASAN --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist= // CHECK-DEFAULT-BLACKLIST-ASAN: -fsanitize-blacklist={{.*[^w]}}asan_blacklist.txt Index: clang/test/Frontend/dependency-gen.c =================================================================== --- clang/test/Frontend/dependency-gen.c +++ clang/test/Frontend/dependency-gen.c @@ -27,3 +27,11 @@ #ifndef INCLUDE_FLAG_TEST #include #endif + +// RUN: echo "fun:foo" > %t.blacklist1 +// RUN: echo "fun:foo" > %t.blacklist2 +// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist1 -fsanitize-blacklist=%t.blacklist2 -I ./ | FileCheck -check-prefix=CHECK-DAG-TWO-BLACK-LISTS %s +// CHECK-DAG-TWO-BLACK-LISTS: resource_dir_with_cfi_blacklist +// CHECK-DAG-TWO-BLACK-LISTS: .blacklist1 +// CHECK-DAG-TWO-BLACK-LISTS: .blacklist2 +// CHECK-DAG-TWO-BLACK-LISTS: {{ }}x.h \ No newline at end of file