diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -882,11 +882,11 @@ Generalize pointers in CFI indirect call type signature checks -.. option:: -fsanitize-coverage-blacklist= +.. option:: -fsanitize-coverage-blocklist= Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the whitelisted ones -.. option:: -fsanitize-coverage-whitelist= +.. option:: -fsanitize-coverage-allowlist= Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blacklisted ones diff --git a/clang/docs/SanitizerCoverage.rst b/clang/docs/SanitizerCoverage.rst --- a/clang/docs/SanitizerCoverage.rst +++ b/clang/docs/SanitizerCoverage.rst @@ -317,8 +317,8 @@ It is sometimes useful to tell SanitizerCoverage to instrument only a subset of the functions in your target. -With ``-fsanitize-coverage-whitelist=whitelist.txt`` -and ``-fsanitize-coverage-blacklist=blacklist.txt``, +With ``-fsanitize-coverage-allowlist=whitelist.txt`` +and ``-fsanitize-coverage-blocklist=blacklist.txt``, you can specify such a subset through the combination of a whitelist and a blacklist. SanitizerCoverage will only instrument functions that satisfy two conditions. diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -325,12 +325,12 @@ /// Path to whitelist file specifying which objects /// (files, functions) should exclusively be instrumented /// by sanitizer coverage pass. - std::vector SanitizeCoverageWhitelistFiles; + std::vector SanitizeCoverageAllowlistFiles; /// Path to blacklist file specifying which objects /// (files, functions) listed for instrumentation by sanitizer /// coverage pass should actually not be instrumented. - std::vector SanitizeCoverageBlacklistFiles; + std::vector SanitizeCoverageBlocklistFiles; /// Executable and command-line used to create a given CompilerInvocation. /// Most of the time this will be the full -cc1 command. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -996,12 +996,16 @@ Group, Flags<[CoreOption, DriverOption]>, HelpText<"Disable specified features of coverage instrumentation for " "Sanitizers">, Values<"func,bb,edge,indirect-calls,trace-bb,trace-cmp,trace-div,trace-gep,8bit-counters,trace-pc,trace-pc-guard,no-prune,inline-8bit-counters,inline-bool-flag">; -def fsanitize_coverage_whitelist : Joined<["-"], "fsanitize-coverage-whitelist=">, +def fsanitize_coverage_allowlist : Joined<["-"], "fsanitize-coverage-allowlist=">, Group, Flags<[CoreOption, DriverOption]>, HelpText<"Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blacklisted ones">; -def fsanitize_coverage_blacklist : Joined<["-"], "fsanitize-coverage-blacklist=">, +def : Joined<["-"], "fsanitize-coverage-whitelist=">, + Group, Flags<[CoreOption, DriverOption]>, Alias; +def fsanitize_coverage_blocklist : Joined<["-"], "fsanitize-coverage-blocklist=">, Group, Flags<[CoreOption, DriverOption]>, HelpText<"Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the whitelisted ones">; +def : Joined<["-"], "fsanitize-coverage-blacklist=">, + Group, Flags<[CoreOption, DriverOption]>, Alias; def fsanitize_memory_track_origins_EQ : Joined<["-"], "fsanitize-memory-track-origins=">, Group, HelpText<"Enable origins tracking in MemorySanitizer">; diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -238,8 +238,8 @@ const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); auto Opts = getSancovOptsFromCGOpts(CGOpts); PM.add(createModuleSanitizerCoverageLegacyPassPass( - Opts, CGOpts.SanitizeCoverageWhitelistFiles, - CGOpts.SanitizeCoverageBlacklistFiles)); + Opts, CGOpts.SanitizeCoverageAllowlistFiles, + CGOpts.SanitizeCoverageBlocklistFiles)); } // Check if ASan should use GC-friendly instrumentation for globals. @@ -1022,8 +1022,8 @@ CodeGenOpts.SanitizeCoverageTraceCmp) { auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); MPM.addPass(ModuleSanitizerCoveragePass( - SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles, - CodeGenOpts.SanitizeCoverageBlacklistFiles)); + SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles, + CodeGenOpts.SanitizeCoverageBlocklistFiles)); } auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) { @@ -1282,8 +1282,8 @@ PassBuilder::OptimizationLevel Level) { auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); MPM.addPass(ModuleSanitizerCoveragePass( - SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles, - CodeGenOpts.SanitizeCoverageBlacklistFiles)); + SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles, + CodeGenOpts.SanitizeCoverageBlocklistFiles)); }); } diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -746,11 +746,11 @@ if (CoverageFeatures) { parseSpecialCaseListArg( D, Args, CoverageWhitelistFiles, - options::OPT_fsanitize_coverage_whitelist, OptSpecifier(), + options::OPT_fsanitize_coverage_allowlist, OptSpecifier(), clang::diag::err_drv_malformed_sanitizer_coverage_whitelist); parseSpecialCaseListArg( D, Args, CoverageBlacklistFiles, - options::OPT_fsanitize_coverage_blacklist, OptSpecifier(), + options::OPT_fsanitize_coverage_blocklist, OptSpecifier(), clang::diag::err_drv_malformed_sanitizer_coverage_blacklist); } @@ -954,9 +954,9 @@ CmdArgs.push_back(F.second); } addSpecialCaseListOpt( - Args, CmdArgs, "-fsanitize-coverage-whitelist=", CoverageWhitelistFiles); + Args, CmdArgs, "-fsanitize-coverage-allowlist=", CoverageWhitelistFiles); addSpecialCaseListOpt( - Args, CmdArgs, "-fsanitize-coverage-blacklist=", CoverageBlacklistFiles); + Args, CmdArgs, "-fsanitize-coverage-blocklist=", CoverageBlacklistFiles); if (TC.getTriple().isOSWindows() && needsUbsanRt()) { // Instruct the code generator to embed linker directives in the object file diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1170,10 +1170,10 @@ Opts.SanitizeCoveragePCTable = Args.hasArg(OPT_fsanitize_coverage_pc_table); Opts.SanitizeCoverageStackDepth = Args.hasArg(OPT_fsanitize_coverage_stack_depth); - Opts.SanitizeCoverageWhitelistFiles = - Args.getAllArgValues(OPT_fsanitize_coverage_whitelist); - Opts.SanitizeCoverageBlacklistFiles = - Args.getAllArgValues(OPT_fsanitize_coverage_blacklist); + Opts.SanitizeCoverageAllowlistFiles = + Args.getAllArgValues(OPT_fsanitize_coverage_allowlist); + Opts.SanitizeCoverageBlocklistFiles = + Args.getAllArgValues(OPT_fsanitize_coverage_blocklist); Opts.SanitizeMemoryTrackOrigins = getLastArgIntValue(Args, OPT_fsanitize_memory_track_origins_EQ, 0, Diags); Opts.SanitizeMemoryUseAfterDtor = diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp rename from compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp rename to compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp @@ -1,5 +1,5 @@ -// Tests -fsanitize-coverage-whitelist=whitelist.txt and -// -fsanitize-coverage-blacklist=blacklist.txt with libFuzzer-like coverage +// Tests -fsanitize-coverage-allowlist=whitelist.txt and +// -fsanitize-coverage-blocklist=blacklist.txt with libFuzzer-like coverage // options // REQUIRES: has_sancovcc,stable-runtime @@ -38,52 +38,55 @@ // RUN: echo 'section "__sancov_pcs"' >> patterns.txt // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table 2>&1 | grep -f patterns.txt | count 14 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt 2>&1 | grep -f patterns.txt | count 14 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_file.txt 2>&1 | grep -f patterns.txt | count 14 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_foo.txt 2>&1 | grep -f patterns.txt | count 9 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_bar.txt 2>&1 | grep -f patterns.txt | count 5 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_all.txt 2>&1 | grep -f patterns.txt | count 14 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_none.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_file.txt 2>&1 | grep -f patterns.txt | count 14 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_foo.txt 2>&1 | grep -f patterns.txt | count 9 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_bar.txt 2>&1 | grep -f patterns.txt | count 5 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_file.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_foo.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_bar.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_all.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_none.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_file.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_foo.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_bar.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-whitelist=wl_all.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-whitelist=wl_none.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-whitelist=wl_file.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-whitelist=wl_foo.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-whitelist=wl_bar.txt -fsanitize-coverage-blacklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-allowlist=wl_all.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-allowlist=wl_none.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-allowlist=wl_file.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-allowlist=wl_foo.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fexperimental-new-pass-manager -fsanitize-coverage-allowlist=wl_bar.txt -fsanitize-coverage-blocklist=bl_all.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blacklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 14 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt -fsanitize-coverage-blacklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 14 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt -fsanitize-coverage-blacklist=bl_none.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_file.txt -fsanitize-coverage-blacklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 14 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_foo.txt -fsanitize-coverage-blacklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 9 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_bar.txt -fsanitize-coverage-blacklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 5 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blocklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 14 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_all.txt -fsanitize-coverage-blocklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 14 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_none.txt -fsanitize-coverage-blocklist=bl_none.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_file.txt -fsanitize-coverage-blocklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 14 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_foo.txt -fsanitize-coverage-blocklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 9 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_bar.txt -fsanitize-coverage-blocklist=bl_none.txt 2>&1 | grep -f patterns.txt | count 5 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blacklist=bl_file.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt -fsanitize-coverage-blacklist=bl_file.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt -fsanitize-coverage-blacklist=bl_file.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_file.txt -fsanitize-coverage-blacklist=bl_file.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_foo.txt -fsanitize-coverage-blacklist=bl_file.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_bar.txt -fsanitize-coverage-blacklist=bl_file.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blocklist=bl_file.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_all.txt -fsanitize-coverage-blocklist=bl_file.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_none.txt -fsanitize-coverage-blocklist=bl_file.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_file.txt -fsanitize-coverage-blocklist=bl_file.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_foo.txt -fsanitize-coverage-blocklist=bl_file.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_bar.txt -fsanitize-coverage-blocklist=bl_file.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blacklist=bl_foo.txt 2>&1 | grep -f patterns.txt | count 5 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt -fsanitize-coverage-blacklist=bl_foo.txt 2>&1 | grep -f patterns.txt | count 5 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt -fsanitize-coverage-blacklist=bl_foo.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_file.txt -fsanitize-coverage-blacklist=bl_foo.txt 2>&1 | grep -f patterns.txt | count 5 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_foo.txt -fsanitize-coverage-blacklist=bl_foo.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_bar.txt -fsanitize-coverage-blacklist=bl_foo.txt 2>&1 | grep -f patterns.txt | count 5 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blocklist=bl_foo.txt 2>&1 | grep -f patterns.txt | count 5 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_all.txt -fsanitize-coverage-blocklist=bl_foo.txt 2>&1 | grep -f patterns.txt | count 5 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_none.txt -fsanitize-coverage-blocklist=bl_foo.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_file.txt -fsanitize-coverage-blocklist=bl_foo.txt 2>&1 | grep -f patterns.txt | count 5 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_foo.txt -fsanitize-coverage-blocklist=bl_foo.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_bar.txt -fsanitize-coverage-blocklist=bl_foo.txt 2>&1 | grep -f patterns.txt | count 5 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blacklist=bl_bar.txt 2>&1 | grep -f patterns.txt | count 9 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt -fsanitize-coverage-blacklist=bl_bar.txt 2>&1 | grep -f patterns.txt | count 9 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt -fsanitize-coverage-blacklist=bl_bar.txt 2>&1 | not grep -f patterns.txt -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_file.txt -fsanitize-coverage-blacklist=bl_bar.txt 2>&1 | grep -f patterns.txt | count 9 -// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_foo.txt -fsanitize-coverage-blacklist=bl_bar.txt 2>&1 | grep -f patterns.txt | count 9 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-blocklist=bl_bar.txt 2>&1 | grep -f patterns.txt | count 9 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_all.txt -fsanitize-coverage-blocklist=bl_bar.txt 2>&1 | grep -f patterns.txt | count 9 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_none.txt -fsanitize-coverage-blocklist=bl_bar.txt 2>&1 | not grep -f patterns.txt +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_file.txt -fsanitize-coverage-blocklist=bl_bar.txt 2>&1 | grep -f patterns.txt | count 9 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_foo.txt -fsanitize-coverage-blocklist=bl_bar.txt 2>&1 | grep -f patterns.txt | count 9 +// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_bar.txt -fsanitize-coverage-blocklist=bl_bar.txt 2>&1 | not grep -f patterns.txt + +/// Kept for compatibility. // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_bar.txt -fsanitize-coverage-blacklist=bl_bar.txt 2>&1 | not grep -f patterns.txt // RUN: cd - diff --git a/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h b/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h --- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h +++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h @@ -32,16 +32,16 @@ public: explicit ModuleSanitizerCoveragePass( SanitizerCoverageOptions Options = SanitizerCoverageOptions(), - const std::vector &WhitelistFiles = + const std::vector &AllowlistFiles = std::vector(), - const std::vector &BlacklistFiles = + const std::vector &BlocklistFiles = std::vector()) : Options(Options) { - if (WhitelistFiles.size() > 0) - Whitelist = SpecialCaseList::createOrDie(WhitelistFiles, + if (AllowlistFiles.size() > 0) + Allowlist = SpecialCaseList::createOrDie(AllowlistFiles, *vfs::getRealFileSystem()); - if (BlacklistFiles.size() > 0) - Blacklist = SpecialCaseList::createOrDie(BlacklistFiles, + if (BlocklistFiles.size() > 0) + Blocklist = SpecialCaseList::createOrDie(BlocklistFiles, *vfs::getRealFileSystem()); } PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); @@ -49,15 +49,15 @@ private: SanitizerCoverageOptions Options; - std::unique_ptr Whitelist; - std::unique_ptr Blacklist; + std::unique_ptr Allowlist; + std::unique_ptr Blocklist; }; // Insert SanitizerCoverage instrumentation. ModulePass *createModuleSanitizerCoverageLegacyPassPass( const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(), - const std::vector &WhitelistFiles = std::vector(), - const std::vector &BlacklistFiles = + const std::vector &AllowlistFiles = std::vector(), + const std::vector &BlocklistFiles = std::vector()); } // namespace llvm diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -200,10 +200,10 @@ public: ModuleSanitizerCoverage( const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(), - const SpecialCaseList *Whitelist = nullptr, - const SpecialCaseList *Blacklist = nullptr) - : Options(OverrideFromCL(Options)), Whitelist(Whitelist), - Blacklist(Blacklist) {} + const SpecialCaseList *Allowlist = nullptr, + const SpecialCaseList *Blocklist = nullptr) + : Options(OverrideFromCL(Options)), Allowlist(Allowlist), + Blocklist(Blocklist) {} bool instrumentModule(Module &M, DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback); @@ -268,31 +268,31 @@ SanitizerCoverageOptions Options; - const SpecialCaseList *Whitelist; - const SpecialCaseList *Blacklist; + const SpecialCaseList *Allowlist; + const SpecialCaseList *Blocklist; }; class ModuleSanitizerCoverageLegacyPass : public ModulePass { public: ModuleSanitizerCoverageLegacyPass( const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(), - const std::vector &WhitelistFiles = + const std::vector &AllowlistFiles = std::vector(), - const std::vector &BlacklistFiles = + const std::vector &BlocklistFiles = std::vector()) : ModulePass(ID), Options(Options) { - if (WhitelistFiles.size() > 0) - Whitelist = SpecialCaseList::createOrDie(WhitelistFiles, + if (AllowlistFiles.size() > 0) + Allowlist = SpecialCaseList::createOrDie(AllowlistFiles, *vfs::getRealFileSystem()); - if (BlacklistFiles.size() > 0) - Blacklist = SpecialCaseList::createOrDie(BlacklistFiles, + if (BlocklistFiles.size() > 0) + Blocklist = SpecialCaseList::createOrDie(BlocklistFiles, *vfs::getRealFileSystem()); initializeModuleSanitizerCoverageLegacyPassPass( *PassRegistry::getPassRegistry()); } bool runOnModule(Module &M) override { - ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(), - Blacklist.get()); + ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(), + Blocklist.get()); auto DTCallback = [this](Function &F) -> const DominatorTree * { return &this->getAnalysis(F).getDomTree(); }; @@ -314,16 +314,16 @@ private: SanitizerCoverageOptions Options; - std::unique_ptr Whitelist; - std::unique_ptr Blacklist; + std::unique_ptr Allowlist; + std::unique_ptr Blocklist; }; } // namespace PreservedAnalyses ModuleSanitizerCoveragePass::run(Module &M, ModuleAnalysisManager &MAM) { - ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(), - Blacklist.get()); + ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(), + Blocklist.get()); auto &FAM = MAM.getResult(M).getManager(); auto DTCallback = [&FAM](Function &F) -> const DominatorTree * { return &FAM.getResult(F); @@ -396,11 +396,11 @@ Module &M, DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback) { if (Options.CoverageType == SanitizerCoverageOptions::SCK_None) return false; - if (Whitelist && - !Whitelist->inSection("coverage", "src", M.getSourceFileName())) + if (Allowlist && + !Allowlist->inSection("coverage", "src", M.getSourceFileName())) return false; - if (Blacklist && - Blacklist->inSection("coverage", "src", M.getSourceFileName())) + if (Blocklist && + Blocklist->inSection("coverage", "src", M.getSourceFileName())) return false; C = &(M.getContext()); DL = &M.getDataLayout(); @@ -639,9 +639,9 @@ if (F.hasPersonalityFn() && isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn()))) return; - if (Whitelist && !Whitelist->inSection("coverage", "fun", F.getName())) + if (Allowlist && !Allowlist->inSection("coverage", "fun", F.getName())) return; - if (Blacklist && Blacklist->inSection("coverage", "fun", F.getName())) + if (Blocklist && Blocklist->inSection("coverage", "fun", F.getName())) return; if (Options.CoverageType >= SanitizerCoverageOptions::SCK_Edge) SplitAllCriticalEdges(F, CriticalEdgeSplittingOptions().setIgnoreUnreachableDests()); @@ -1014,8 +1014,8 @@ false) ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass( const SanitizerCoverageOptions &Options, - const std::vector &WhitelistFiles, - const std::vector &BlacklistFiles) { - return new ModuleSanitizerCoverageLegacyPass(Options, WhitelistFiles, - BlacklistFiles); + const std::vector &AllowlistFiles, + const std::vector &BlocklistFiles) { + return new ModuleSanitizerCoverageLegacyPass(Options, AllowlistFiles, + BlocklistFiles); }