diff --git a/llvm/docs/CommandGuide/llvm-cov.rst b/llvm/docs/CommandGuide/llvm-cov.rst --- a/llvm/docs/CommandGuide/llvm-cov.rst +++ b/llvm/docs/CommandGuide/llvm-cov.rst @@ -265,10 +265,10 @@ Show code coverage only for functions with the given name. -.. option:: -name-whitelist= +.. option:: -name-allowlist= Show code coverage only for functions listed in the given file. Each line in - the file should start with `whitelist_fun:`, immediately followed by the name + the file should start with `allowlist_fun:`, immediately followed by the name of the function to accept. This name can be a wildcard expression. .. option:: -name-regex= diff --git a/llvm/test/tools/llvm-cov/Inputs/allowlist1.txt b/llvm/test/tools/llvm-cov/Inputs/allowlist1.txt new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-cov/Inputs/allowlist1.txt @@ -0,0 +1,4 @@ +# Comment + +allowlist_fun:*func1* +allowlist_fun:*func2* diff --git a/llvm/test/tools/llvm-cov/Inputs/allowlist2.txt b/llvm/test/tools/llvm-cov/Inputs/allowlist2.txt new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-cov/Inputs/allowlist2.txt @@ -0,0 +1,2 @@ +allowlist_fun:*func3* +allowlist_fun:*func4* diff --git a/llvm/test/tools/llvm-cov/Inputs/name_whitelist.covmapping b/llvm/test/tools/llvm-cov/Inputs/name_allowlist.covmapping old mode 100644 new mode 100755 rename from llvm/test/tools/llvm-cov/Inputs/name_whitelist.covmapping rename to llvm/test/tools/llvm-cov/Inputs/name_allowlist.covmapping index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@ %t.one_list +RUN: FileCheck -input-file=%t.one_list -check-prefix=ONE_ALLOWLIST %s +RUN: FileCheck -input-file=%t.one_list -check-prefix=ONE_ALLOWLIST_NEG %s +ONE_ALLOWLIST: _Z5func1v: +ONE_ALLOWLIST: _Z5func2v: +ONE_ALLOWLIST_NEG-NOT: _Z5func3v: +ONE_ALLOWLIST_NEG-NOT: _Z5func4v: +ONE_ALLOWLIST_NEG-NOT: _Z5func5v: +ONE_ALLOWLIST_NEG-NOT: _Z5func6v: + +RUN: llvm-cov show %S/Inputs/name_allowlist.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S/Inputs -name-allowlist=%S/Inputs/allowlist1.txt -name-allowlist=%S/Inputs/allowlist2.txt %S/Inputs/name_allowlist.cpp > %t.two_list +RUN: FileCheck -input-file=%t.two_list -check-prefix=TWO_ALLOWLIST %s +RUN: FileCheck -input-file=%t.two_list -check-prefix=TWO_ALLOWLIST_NEG %s +TWO_ALLOWLIST: _Z5func1v: +TWO_ALLOWLIST: _Z5func2v: +TWO_ALLOWLIST: _Z5func3v: +TWO_ALLOWLIST: _Z5func4v: +TWO_ALLOWLIST_NEG-NOT: _Z5func5v: +TWO_ALLOWLIST_NEG-NOT: _Z5func6v: diff --git a/llvm/test/tools/llvm-cov/name_whitelist.test b/llvm/test/tools/llvm-cov/name_whitelist.test deleted file mode 100644 --- a/llvm/test/tools/llvm-cov/name_whitelist.test +++ /dev/null @@ -1,21 +0,0 @@ -RUN: llvm-profdata merge %S/Inputs/name_whitelist.proftext -o %t.profdata - -RUN: llvm-cov show %S/Inputs/name_whitelist.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S/Inputs -name-whitelist=%S/Inputs/whitelist1.txt %S/Inputs/name_whitelist.cpp > %t.one_list -RUN: FileCheck -input-file=%t.one_list -check-prefix=ONE_WHITELIST %s -RUN: FileCheck -input-file=%t.one_list -check-prefix=ONE_WHITELIST_NEG %s -ONE_WHITELIST: _Z5func1v: -ONE_WHITELIST: _Z5func2v: -ONE_WHITELIST_NEG-NOT: _Z5func3v: -ONE_WHITELIST_NEG-NOT: _Z5func4v: -ONE_WHITELIST_NEG-NOT: _Z5func5v: -ONE_WHITELIST_NEG-NOT: _Z5func6v: - -RUN: llvm-cov show %S/Inputs/name_whitelist.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S/Inputs -name-whitelist=%S/Inputs/whitelist1.txt -name-whitelist=%S/Inputs/whitelist2.txt %S/Inputs/name_whitelist.cpp > %t.two_list -RUN: FileCheck -input-file=%t.two_list -check-prefix=TWO_WHITELIST %s -RUN: FileCheck -input-file=%t.two_list -check-prefix=TWO_WHITELIST_NEG %s -TWO_WHITELIST: _Z5func1v: -TWO_WHITELIST: _Z5func2v: -TWO_WHITELIST: _Z5func3v: -TWO_WHITELIST: _Z5func4v: -TWO_WHITELIST_NEG-NOT: _Z5func5v: -TWO_WHITELIST_NEG-NOT: _Z5func6v: diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -176,8 +176,8 @@ std::vector>> LoadedSourceFiles; - /// Whitelist from -name-whitelist to be used for filtering. - std::unique_ptr NameWhitelist; + /// Allowlist from -name-allowlist to be used for filtering. + std::unique_ptr NameAllowlist; }; } @@ -668,7 +668,7 @@ cl::ZeroOrMore, cl::cat(FilteringCategory)); cl::list NameFilterFiles( - "name-whitelist", cl::Optional, + "name-allowlist", cl::Optional, cl::desc("Show code coverage only for functions listed in the given " "file"), cl::ZeroOrMore, cl::cat(FilteringCategory)); @@ -809,23 +809,23 @@ ViewOpts.DemanglerOpts.swap(DemanglerOpts); } - // Read in -name-whitelist files. + // Read in -name-allowlist files. if (!NameFilterFiles.empty()) { std::string SpecialCaseListErr; - NameWhitelist = SpecialCaseList::create( + NameAllowlist = SpecialCaseList::create( NameFilterFiles, *vfs::getRealFileSystem(), SpecialCaseListErr); - if (!NameWhitelist) + if (!NameAllowlist) error(SpecialCaseListErr); } // Create the function filters - if (!NameFilters.empty() || NameWhitelist || !NameRegexFilters.empty()) { + if (!NameFilters.empty() || NameAllowlist || !NameRegexFilters.empty()) { auto NameFilterer = std::make_unique(); for (const auto &Name : NameFilters) NameFilterer->push_back(std::make_unique(Name)); - if (NameWhitelist) + if (NameAllowlist) NameFilterer->push_back( - std::make_unique(*NameWhitelist)); + std::make_unique(*NameAllowlist)); for (const auto &Regex : NameRegexFilters) NameFilterer->push_back( std::make_unique(Regex)); diff --git a/llvm/tools/llvm-cov/CoverageFilters.h b/llvm/tools/llvm-cov/CoverageFilters.h --- a/llvm/tools/llvm-cov/CoverageFilters.h +++ b/llvm/tools/llvm-cov/CoverageFilters.h @@ -67,13 +67,13 @@ }; /// Matches functions whose name appears in a SpecialCaseList in the -/// whitelist_fun section. -class NameWhitelistCoverageFilter : public CoverageFilter { - const SpecialCaseList &Whitelist; +/// allowlist_fun section. +class NameAllowlistCoverageFilter : public CoverageFilter { + const SpecialCaseList &Allowlist; public: - NameWhitelistCoverageFilter(const SpecialCaseList &Whitelist) - : Whitelist(Whitelist) {} + NameAllowlistCoverageFilter(const SpecialCaseList &Allowlist) + : Allowlist(Allowlist) {} bool matches(const coverage::CoverageMapping &CM, const coverage::FunctionRecord &Function) const override; diff --git a/llvm/tools/llvm-cov/CoverageFilters.cpp b/llvm/tools/llvm-cov/CoverageFilters.cpp --- a/llvm/tools/llvm-cov/CoverageFilters.cpp +++ b/llvm/tools/llvm-cov/CoverageFilters.cpp @@ -34,10 +34,10 @@ return llvm::Regex(Regex).match(Filename); } -bool NameWhitelistCoverageFilter::matches( +bool NameAllowlistCoverageFilter::matches( const coverage::CoverageMapping &, const coverage::FunctionRecord &Function) const { - return Whitelist.inSection("llvmcov", "whitelist_fun", Function.Name); + return Allowlist.inSection("llvmcov", "allowlist_fun", Function.Name); } bool RegionCoverageFilter::matches(