[SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

Keep deprecated -fsanitize-coverage-{white,black}list as aliases for compatibility for now.

Reviewed By: echristo

Differential Revision: https://reviews.llvm.org/D82244
This commit is contained in:
Fangrui Song
2020-06-19 22:22:47 -07:00
committed by Fangrui Song
parent 6429471e8b
commit 2a4317bfb3
11 changed files with 143 additions and 135 deletions
+4 -4
View File
@@ -882,13 +882,13 @@ Enable control flow integrity (CFI) checks for cross-DSO calls.
Generalize pointers in CFI indirect call type signature checks
.. option:: -fsanitize-coverage-blacklist=<arg>
.. option:: -fsanitize-coverage-allowlist=<arg>
Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the whitelisted ones
Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blocked ones
.. option:: -fsanitize-coverage-whitelist=<arg>
.. option:: -fsanitize-coverage-blocklist=<arg>
Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blacklisted ones
Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the allowed ones
.. option:: -fsanitize-coverage=<arg1>,<arg2>..., -fno-sanitize-coverage=<arg1>,<arg2>...
+18 -18
View File
@@ -317,24 +317,24 @@ Partially disabling instrumentation
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``,
you can specify such a subset through the combination of a whitelist and a blacklist.
With ``-fsanitize-coverage-allowlist=allowlist.txt``
and ``-fsanitize-coverage-blocklist=blocklist.txt``,
you can specify such a subset through the combination of a allowlist and a blocklist.
SanitizerCoverage will only instrument functions that satisfy two conditions.
First, the function should belong to a source file with a path that is both whitelisted
and not blacklisted.
Second, the function should have a mangled name that is both whitelisted and not blacklisted.
First, the function should belong to a source file with a path that is both allowlisted
and not blocklisted.
Second, the function should have a mangled name that is both allowlisted and not blocklisted.
The whitelist and blacklist format is similar to that of the sanitizer blacklist format.
The default whitelist will match every source file and every function.
The default blacklist will match no source file and no function.
The allowlist and blocklist format is similar to that of the sanitizer blocklist format.
The default allowlist will match every source file and every function.
The default blocklist will match no source file and no function.
A common use case is to have the whitelist list folders or source files for which you want
instrumentation and allow all function names, while the blacklist will opt out some specific
files or functions that the whitelist loosely allowed.
A common use case is to have the allowlist list folders or source files for which you want
instrumentation and allow all function names, while the blocklist will opt out some specific
files or functions that the allowlist loosely allowed.
Here is an example whitelist:
Here is an example allowlist:
.. code-block:: none
@@ -345,13 +345,13 @@ Here is an example whitelist:
# Enable instrumentation for all functions in those files
fun:*
And an example blacklist:
And an example blocklist:
.. code-block:: none
# Disable instrumentation for a specific source file that the whitelist allowed
# Disable instrumentation for a specific source file that the allowlist allowed
src:bar/b.cpp
# Disable instrumentation for a specific function that the whitelist allowed
# Disable instrumentation for a specific function that the allowlist allowed
fun:*myFunc*
The use of ``*`` wildcards above is required because function names are matched after mangling.
@@ -359,7 +359,7 @@ Without the wildcards, one would have to write the whole mangled name.
Be careful that the paths of source files are matched exactly as they are provided on the clang
command line.
For example, the whitelist above would include file ``bar/b.cpp`` if the path was provided
For example, the allowlist above would include file ``bar/b.cpp`` if the path was provided
exactly like this, but would it would fail to include it with other ways to refer to the same
file such as ``./bar/b.cpp``, or ``bar\b.cpp`` on Windows.
So, please make sure to always double check that your lists are correctly applied.
@@ -432,7 +432,7 @@ Sancov matches these files using module names and binaries file names.
-symbolize - Symbolizes the report.
Options
-blacklist=<string> - Blacklist file (sanitizer blacklist format).
-blocklist=<string> - Blocklist file (sanitizer blocklist format).
-demangle - Print demangled function name.
-strip_path_prefix=<string> - Strip this prefix from file paths in reports
+4 -4
View File
@@ -322,15 +322,15 @@ public:
/// List of dynamic shared object files to be loaded as pass plugins.
std::vector<std::string> PassPlugins;
/// Path to whitelist file specifying which objects
/// Path to allowlist file specifying which objects
/// (files, functions) should exclusively be instrumented
/// by sanitizer coverage pass.
std::vector<std::string> SanitizeCoverageWhitelistFiles;
std::vector<std::string> SanitizeCoverageAllowlistFiles;
/// Path to blacklist file specifying which objects
/// Path to blocklist file specifying which objects
/// (files, functions) listed for instrumentation by sanitizer
/// coverage pass should actually not be instrumented.
std::vector<std::string> SanitizeCoverageBlacklistFiles;
std::vector<std::string> SanitizeCoverageBlocklistFiles;
/// Executable and command-line used to create a given CompilerInvocation.
/// Most of the time this will be the full -cc1 command.
+10 -4
View File
@@ -996,12 +996,18 @@ def fno_sanitize_coverage
Group<f_clang_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<f_clang_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=">,
HelpText<"Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blocked ones">;
def : Joined<["-"], "fsanitize-coverage-whitelist=">,
Group<f_clang_Group>, Flags<[CoreOption, HelpHidden]>, Alias<fsanitize_coverage_allowlist>,
HelpText<"Deprecated, use -fsanitize-coverage-allowlist= instead">;
def fsanitize_coverage_blocklist : Joined<["-"], "fsanitize-coverage-blocklist=">,
Group<f_clang_Group>, Flags<[CoreOption, DriverOption]>,
HelpText<"Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the whitelisted ones">;
HelpText<"Disable sanitizer coverage instrumentation for modules and functions that match the provided special case list, even the allowed ones">;
def : Joined<["-"], "fsanitize-coverage-blacklist=">,
Group<f_clang_Group>, Flags<[CoreOption, HelpHidden]>, Alias<fsanitize_coverage_blocklist>,
HelpText<"Deprecated, use -fsanitize-coverage-blocklist= instead">;
def fsanitize_memory_track_origins_EQ : Joined<["-"], "fsanitize-memory-track-origins=">,
Group<f_clang_Group>,
HelpText<"Enable origins tracking in MemorySanitizer">;
+2 -2
View File
@@ -27,8 +27,8 @@ class SanitizerArgs {
std::vector<std::string> UserBlacklistFiles;
std::vector<std::string> SystemBlacklistFiles;
std::vector<std::string> CoverageWhitelistFiles;
std::vector<std::string> CoverageBlacklistFiles;
std::vector<std::string> CoverageAllowlistFiles;
std::vector<std::string> CoverageBlocklistFiles;
int CoverageFeatures = 0;
int MsanTrackOrigins = 0;
bool MsanUseAfterDtor = true;
+6 -6
View File
@@ -238,8 +238,8 @@ static void addSanitizerCoveragePass(const PassManagerBuilder &Builder,
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 @@ static void addSanitizersAtO0(ModulePassManager &MPM,
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 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
PassBuilder::OptimizationLevel Level) {
auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
MPM.addPass(ModuleSanitizerCoveragePass(
SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
CodeGenOpts.SanitizeCoverageBlacklistFiles));
SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles,
CodeGenOpts.SanitizeCoverageBlocklistFiles));
});
}
+6 -6
View File
@@ -745,12 +745,12 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
// So, there is no way to clear coverage lists but you can append to them.
if (CoverageFeatures) {
parseSpecialCaseListArg(
D, Args, CoverageWhitelistFiles,
options::OPT_fsanitize_coverage_whitelist, OptSpecifier(),
D, Args, CoverageAllowlistFiles,
options::OPT_fsanitize_coverage_allowlist, OptSpecifier(),
clang::diag::err_drv_malformed_sanitizer_coverage_whitelist);
parseSpecialCaseListArg(
D, Args, CoverageBlacklistFiles,
options::OPT_fsanitize_coverage_blacklist, OptSpecifier(),
D, Args, CoverageBlocklistFiles,
options::OPT_fsanitize_coverage_blocklist, OptSpecifier(),
clang::diag::err_drv_malformed_sanitizer_coverage_blacklist);
}
@@ -954,9 +954,9 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
CmdArgs.push_back(F.second);
}
addSpecialCaseListOpt(
Args, CmdArgs, "-fsanitize-coverage-whitelist=", CoverageWhitelistFiles);
Args, CmdArgs, "-fsanitize-coverage-allowlist=", CoverageAllowlistFiles);
addSpecialCaseListOpt(
Args, CmdArgs, "-fsanitize-coverage-blacklist=", CoverageBlacklistFiles);
Args, CmdArgs, "-fsanitize-coverage-blocklist=", CoverageBlocklistFiles);
if (TC.getTriple().isOSWindows() && needsUbsanRt()) {
// Instruct the code generator to embed linker directives in the object file
+4 -4
View File
@@ -1170,10 +1170,10 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
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 =
@@ -1,5 +1,5 @@
// Tests -fsanitize-coverage-whitelist=whitelist.txt and
// -fsanitize-coverage-blacklist=blacklist.txt with libFuzzer-like coverage
// Tests -fsanitize-coverage-allowlist=allowlist.txt and
// -fsanitize-coverage-blocklist=blocklist.txt with libFuzzer-like coverage
// options
// REQUIRES: has_sancovcc,stable-runtime
@@ -12,11 +12,11 @@
// RUN: mkdir -p $DIR
// RUN: cd $DIR
// RUN: echo -e "src:*\nfun:*" > wl_all.txt
// RUN: echo -e "" > wl_none.txt
// RUN: echo -e "src:%s\nfun:*" > wl_file.txt
// RUN: echo -e "src:*\nfun:*bar*" > wl_bar.txt
// RUN: echo -e "src:*\nfun:*foo*" > wl_foo.txt
// RUN: echo -e "src:*\nfun:*" > al_all.txt
// RUN: echo -e "" > al_none.txt
// RUN: echo -e "src:%s\nfun:*" > al_file.txt
// RUN: echo -e "src:*\nfun:*bar*" > al_bar.txt
// RUN: echo -e "src:*\nfun:*foo*" > al_foo.txt
// RUN: echo -e "src:*" > bl_all.txt
// RUN: echo -e "" > bl_none.txt
// RUN: echo -e "src:%s" > bl_file.txt
@@ -38,58 +38,60 @@
// 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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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=al_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-whitelist=wl_bar.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-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=al_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=al_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=al_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=al_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=al_bar.txt -fsanitize-coverage-blocklist=bl_bar.txt 2>&1 | not grep -f patterns.txt
/// The options below are deprecated and will be removed.
// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=al_bar.txt -fsanitize-coverage-blacklist=bl_bar.txt 2>&1 | not grep -f patterns.txt
// RUN: cd -
// RUN: rm -rf $DIR
// foo has 3 instrumentation points, 0 indirect call, 1 comparison point
// Expected results with patterns.txt when foo gets instrumentation with
@@ -32,16 +32,16 @@ class ModuleSanitizerCoveragePass
public:
explicit ModuleSanitizerCoveragePass(
SanitizerCoverageOptions Options = SanitizerCoverageOptions(),
const std::vector<std::string> &WhitelistFiles =
const std::vector<std::string> &AllowlistFiles =
std::vector<std::string>(),
const std::vector<std::string> &BlacklistFiles =
const std::vector<std::string> &BlocklistFiles =
std::vector<std::string>())
: 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 @@ public:
private:
SanitizerCoverageOptions Options;
std::unique_ptr<SpecialCaseList> Whitelist;
std::unique_ptr<SpecialCaseList> Blacklist;
std::unique_ptr<SpecialCaseList> Allowlist;
std::unique_ptr<SpecialCaseList> Blocklist;
};
// Insert SanitizerCoverage instrumentation.
ModulePass *createModuleSanitizerCoverageLegacyPassPass(
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
const std::vector<std::string> &WhitelistFiles = std::vector<std::string>(),
const std::vector<std::string> &BlacklistFiles =
const std::vector<std::string> &AllowlistFiles = std::vector<std::string>(),
const std::vector<std::string> &BlocklistFiles =
std::vector<std::string>());
} // namespace llvm
@@ -200,10 +200,10 @@ class ModuleSanitizerCoverage {
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 @@ private:
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<std::string> &WhitelistFiles =
const std::vector<std::string> &AllowlistFiles =
std::vector<std::string>(),
const std::vector<std::string> &BlacklistFiles =
const std::vector<std::string> &BlocklistFiles =
std::vector<std::string>())
: 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<DominatorTreeWrapperPass>(F).getDomTree();
};
@@ -314,16 +314,16 @@ public:
private:
SanitizerCoverageOptions Options;
std::unique_ptr<SpecialCaseList> Whitelist;
std::unique_ptr<SpecialCaseList> Blacklist;
std::unique_ptr<SpecialCaseList> Allowlist;
std::unique_ptr<SpecialCaseList> 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<FunctionAnalysisManagerModuleProxy>(M).getManager();
auto DTCallback = [&FAM](Function &F) -> const DominatorTree * {
return &FAM.getResult<DominatorTreeAnalysis>(F);
@@ -396,11 +396,11 @@ bool ModuleSanitizerCoverage::instrumentModule(
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 @@ void ModuleSanitizerCoverage::instrumentFunction(
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 @@ INITIALIZE_PASS_END(ModuleSanitizerCoverageLegacyPass, "sancov",
false)
ModulePass *llvm::createModuleSanitizerCoverageLegacyPassPass(
const SanitizerCoverageOptions &Options,
const std::vector<std::string> &WhitelistFiles,
const std::vector<std::string> &BlacklistFiles) {
return new ModuleSanitizerCoverageLegacyPass(Options, WhitelistFiles,
BlacklistFiles);
const std::vector<std::string> &AllowlistFiles,
const std::vector<std::string> &BlocklistFiles) {
return new ModuleSanitizerCoverageLegacyPass(Options, AllowlistFiles,
BlocklistFiles);
}