[clang] e64fcdf - [clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to NoSanitizeList.h
Melanie Blower via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 22 12:11:55 PST 2021
Author: Melanie Blower
Date: 2021-02-22T15:11:37-05:00
New Revision: e64fcdf8d53c1d2ab709394c39743fa11d270181
URL: https://github.com/llvm/llvm-project/commit/e64fcdf8d53c1d2ab709394c39743fa11d270181
DIFF: https://github.com/llvm/llvm-project/commit/e64fcdf8d53c1d2ab709394c39743fa11d270181.diff
LOG: [clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to NoSanitizeList.h
This patch responds to a comment from @vitalybuka in D96203: suggestion to
do the change incrementally, and start by modifying this file name. I modified
the file name and made the other changes that follow from that rename.
Reviewers: vitalybuka, echristo, MaskRay, jansvoboda11, aaron.ballman
Differential Revision: https://reviews.llvm.org/D96974
Added:
clang/include/clang/Basic/NoSanitizeList.h
clang/lib/Basic/NoSanitizeList.cpp
Modified:
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Decl.cpp
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/LangOptions.cpp
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/lib/Frontend/CompilerInvocation.cpp
Removed:
clang/include/clang/Basic/SanitizerBlacklist.h
clang/lib/Basic/SanitizerBlacklist.cpp
################################################################################
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index f256f9762b50..8ba4c41aac70 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -34,10 +34,10 @@
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Linkage.h"
+#include "clang/Basic/NoSanitizeList.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/PartialDiagnostic.h"
#include "clang/Basic/ProfileList.h"
-#include "clang/Basic/SanitizerBlacklist.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Basic/XRayLists.h"
@@ -562,9 +562,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// this ASTContext object.
LangOptions &LangOpts;
- /// Blacklist object that is used by sanitizers to decide which
+ /// NoSanitizeList object that is used by sanitizers to decide which
/// entities should not be instrumented.
- std::unique_ptr<SanitizerBlacklist> SanitizerBL;
+ std::unique_ptr<NoSanitizeList> NoSanitizeL;
/// Function filtering mechanism to determine whether a given function
/// should be imbued with the XRay "always" or "never" attributes.
@@ -691,9 +691,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
}
- const SanitizerBlacklist &getSanitizerBlacklist() const {
- return *SanitizerBL;
- }
+ const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
const XRayFunctionFilter &getXRayFilter() const {
return *XRayFilter;
diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 0d14121bac7a..c797167f8fd2 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -264,9 +264,9 @@ class LangOptions : public LangOptionsBase {
/// Set of enabled sanitizers.
SanitizerSet Sanitize;
- /// Paths to blacklist files specifying which objects
+ /// Paths to files specifying which objects
/// (files, functions, variables) should not be instrumented.
- std::vector<std::string> SanitizerBlacklistFiles;
+ std::vector<std::string> NoSanitizeFiles;
/// Paths to the XRay "always instrument" files specifying which
/// objects (files, functions, variables) should be imbued with the XRay
diff --git a/clang/include/clang/Basic/NoSanitizeList.h b/clang/include/clang/Basic/NoSanitizeList.h
new file mode 100644
index 000000000000..3f80e0fdedda
--- /dev/null
+++ b/clang/include/clang/Basic/NoSanitizeList.h
@@ -0,0 +1,50 @@
+//===--- NoSanitizeList.h - List of ignored entities for sanitizers --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// User-provided list of ignored entities used to disable/alter
+// instrumentation done in sanitizers.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_BASIC_NOSANITIZELIST_H
+#define LLVM_CLANG_BASIC_NOSANITIZELIST_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/StringRef.h"
+#include <memory>
+#include <vector>
+
+namespace clang {
+
+class SanitizerMask;
+class SourceManager;
+class SanitizerSpecialCaseList;
+
+class NoSanitizeList {
+ std::unique_ptr<SanitizerSpecialCaseList> SSCL;
+ SourceManager &SM;
+
+public:
+ NoSanitizeList(const std::vector<std::string> &NoSanitizeListPaths,
+ SourceManager &SM);
+ ~NoSanitizeList();
+ bool containsGlobal(SanitizerMask Mask, StringRef GlobalName,
+ StringRef Category = StringRef()) const;
+ bool containsType(SanitizerMask Mask, StringRef MangledTypeName,
+ StringRef Category = StringRef()) const;
+ bool containsFunction(SanitizerMask Mask, StringRef FunctionName) const;
+ bool containsFile(SanitizerMask Mask, StringRef FileName,
+ StringRef Category = StringRef()) const;
+ bool containsLocation(SanitizerMask Mask, SourceLocation Loc,
+ StringRef Category = StringRef()) const;
+};
+
+} // end namespace clang
+
+#endif
diff --git a/clang/include/clang/Basic/SanitizerBlacklist.h b/clang/include/clang/Basic/SanitizerBlacklist.h
deleted file mode 100644
index c874ff28aacc..000000000000
--- a/clang/include/clang/Basic/SanitizerBlacklist.h
+++ /dev/null
@@ -1,49 +0,0 @@
-//===--- SanitizerBlacklist.h - Blacklist for sanitizers --------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// User-provided blacklist used to disable/alter instrumentation done in
-// sanitizers.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_BASIC_SANITIZERBLACKLIST_H
-#define LLVM_CLANG_BASIC_SANITIZERBLACKLIST_H
-
-#include "clang/Basic/LLVM.h"
-#include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/StringRef.h"
-#include <memory>
-#include <vector>
-
-namespace clang {
-
-class SanitizerMask;
-class SourceManager;
-class SanitizerSpecialCaseList;
-
-class SanitizerBlacklist {
- std::unique_ptr<SanitizerSpecialCaseList> SSCL;
- SourceManager &SM;
-
-public:
- SanitizerBlacklist(const std::vector<std::string> &BlacklistPaths,
- SourceManager &SM);
- ~SanitizerBlacklist();
- bool isBlacklistedGlobal(SanitizerMask Mask, StringRef GlobalName,
- StringRef Category = StringRef()) const;
- bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName,
- StringRef Category = StringRef()) const;
- bool isBlacklistedFunction(SanitizerMask Mask, StringRef FunctionName) const;
- bool isBlacklistedFile(SanitizerMask Mask, StringRef FileName,
- StringRef Category = StringRef()) const;
- bool isBlacklistedLocation(SanitizerMask Mask, SourceLocation Loc,
- StringRef Category = StringRef()) const;
-};
-
-} // end namespace clang
-
-#endif
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 33e247d88c9d..fcbc3f6252b6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -56,8 +56,8 @@
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Linkage.h"
#include "clang/Basic/Module.h"
+#include "clang/Basic/NoSanitizeList.h"
#include "clang/Basic/ObjCRuntime.h"
-#include "clang/Basic/SanitizerBlacklist.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Specifiers.h"
@@ -961,7 +961,7 @@ ASTContext::ASTContext(LangOptions &LOpts, SourceManager &SM,
DependentTemplateSpecializationTypes(this_()), AutoTypes(this_()),
SubstTemplateTemplateParmPacks(this_()),
CanonTemplateTemplateParms(this_()), SourceMgr(SM), LangOpts(LOpts),
- SanitizerBL(new SanitizerBlacklist(LangOpts.SanitizerBlacklistFiles, SM)),
+ NoSanitizeL(new NoSanitizeList(LangOpts.NoSanitizeFiles, SM)),
XRayFilter(new XRayFunctionFilter(LangOpts.XRayAlwaysInstrumentFiles,
LangOpts.XRayNeverInstrumentFiles,
LangOpts.XRayAttrListFiles, SM)),
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index feb9b0645ebc..8c986df3e175 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -41,8 +41,8 @@
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Linkage.h"
#include "clang/Basic/Module.h"
+#include "clang/Basic/NoSanitizeList.h"
#include "clang/Basic/PartialDiagnostic.h"
-#include "clang/Basic/SanitizerBlacklist.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
@@ -4594,7 +4594,7 @@ bool RecordDecl::mayInsertExtraPadding(bool EmitRemark) const {
(SanitizerKind::Address | SanitizerKind::KernelAddress);
if (!EnabledAsanMask || !Context.getLangOpts().SanitizeAddressFieldPadding)
return false;
- const auto &Blacklist = Context.getSanitizerBlacklist();
+ const auto &NoSanitizeList = Context.getNoSanitizeList();
const auto *CXXRD = dyn_cast<CXXRecordDecl>(this);
// We may be able to relax some of these requirements.
int ReasonToReject = -1;
@@ -4610,12 +4610,11 @@ bool RecordDecl::mayInsertExtraPadding(bool EmitRemark) const {
ReasonToReject = 4; // has trivial destructor.
else if (CXXRD->isStandardLayout())
ReasonToReject = 5; // is standard layout.
- else if (Blacklist.isBlacklistedLocation(EnabledAsanMask, getLocation(),
+ else if (NoSanitizeList.containsLocation(EnabledAsanMask, getLocation(),
"field-padding"))
ReasonToReject = 6; // is in an excluded file.
- else if (Blacklist.isBlacklistedType(EnabledAsanMask,
- getQualifiedNameAsString(),
- "field-padding"))
+ else if (NoSanitizeList.containsType(
+ EnabledAsanMask, getQualifiedNameAsString(), "field-padding"))
ReasonToReject = 7; // The type is excluded.
if (EmitRemark) {
diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index e5319484393a..709505d502ed 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -60,7 +60,7 @@ add_clang_library(clangBasic
OpenMPKinds.cpp
OperatorPrecedence.cpp
ProfileList.cpp
- SanitizerBlacklist.cpp
+ NoSanitizeList.cpp
SanitizerSpecialCaseList.cpp
Sanitizers.cpp
SourceLocation.cpp
diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index ed275ade4001..dc392d5352aa 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -28,7 +28,7 @@ void LangOptions::resetNonModularOptions() {
#include "clang/Basic/LangOptions.def"
// These options do not affect AST generation.
- SanitizerBlacklistFiles.clear();
+ NoSanitizeFiles.clear();
XRayAlwaysInstrumentFiles.clear();
XRayNeverInstrumentFiles.clear();
diff --git a/clang/lib/Basic/NoSanitizeList.cpp b/clang/lib/Basic/NoSanitizeList.cpp
new file mode 100644
index 000000000000..3efd613b0d33
--- /dev/null
+++ b/clang/lib/Basic/NoSanitizeList.cpp
@@ -0,0 +1,54 @@
+//===--- NoSanitizeList.cpp - Ignored list for sanitizers ----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// User-provided ignore-list used to disable/alter instrumentation done in
+// sanitizers.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Basic/NoSanitizeList.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/SanitizerSpecialCaseList.h"
+#include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/SourceManager.h"
+
+using namespace clang;
+
+NoSanitizeList::NoSanitizeList(const std::vector<std::string> &NoSanitizePaths,
+ SourceManager &SM)
+ : SSCL(SanitizerSpecialCaseList::createOrDie(
+ NoSanitizePaths, SM.getFileManager().getVirtualFileSystem())),
+ SM(SM) {}
+
+NoSanitizeList::~NoSanitizeList() = default;
+
+bool NoSanitizeList::containsGlobal(SanitizerMask Mask, StringRef GlobalName,
+ StringRef Category) const {
+ return SSCL->inSection(Mask, "global", GlobalName, Category);
+}
+
+bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName,
+ StringRef Category) const {
+ return SSCL->inSection(Mask, "type", MangledTypeName, Category);
+}
+
+bool NoSanitizeList::containsFunction(SanitizerMask Mask,
+ StringRef FunctionName) const {
+ return SSCL->inSection(Mask, "fun", FunctionName);
+}
+
+bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
+ StringRef Category) const {
+ return SSCL->inSection(Mask, "src", FileName, Category);
+}
+
+bool NoSanitizeList::containsLocation(SanitizerMask Mask, SourceLocation Loc,
+ StringRef Category) const {
+ return Loc.isValid() &&
+ containsFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
+}
diff --git a/clang/lib/Basic/SanitizerBlacklist.cpp b/clang/lib/Basic/SanitizerBlacklist.cpp
deleted file mode 100644
index feb7cbda39b7..000000000000
--- a/clang/lib/Basic/SanitizerBlacklist.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-//===--- SanitizerBlacklist.cpp - Blacklist for sanitizers ----------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// User-provided blacklist used to disable/alter instrumentation done in
-// sanitizers.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Basic/SanitizerBlacklist.h"
-#include "clang/Basic/FileManager.h"
-#include "clang/Basic/SanitizerSpecialCaseList.h"
-#include "clang/Basic/Sanitizers.h"
-#include "clang/Basic/SourceManager.h"
-
-using namespace clang;
-
-SanitizerBlacklist::SanitizerBlacklist(
- const std::vector<std::string> &BlacklistPaths, SourceManager &SM)
- : SSCL(SanitizerSpecialCaseList::createOrDie(
- BlacklistPaths, SM.getFileManager().getVirtualFileSystem())),
- SM(SM) {}
-
-SanitizerBlacklist::~SanitizerBlacklist() = default;
-
-bool SanitizerBlacklist::isBlacklistedGlobal(SanitizerMask Mask,
- StringRef GlobalName,
- StringRef Category) const {
- return SSCL->inSection(Mask, "global", GlobalName, Category);
-}
-
-bool SanitizerBlacklist::isBlacklistedType(SanitizerMask Mask,
- StringRef MangledTypeName,
- StringRef Category) const {
- return SSCL->inSection(Mask, "type", MangledTypeName, Category);
-}
-
-bool SanitizerBlacklist::isBlacklistedFunction(SanitizerMask Mask,
- StringRef FunctionName) const {
- return SSCL->inSection(Mask, "fun", FunctionName);
-}
-
-bool SanitizerBlacklist::isBlacklistedFile(SanitizerMask Mask,
- StringRef FileName,
- StringRef Category) const {
- return SSCL->inSection(Mask, "src", FileName, Category);
-}
-
-bool SanitizerBlacklist::isBlacklistedLocation(SanitizerMask Mask,
- SourceLocation Loc,
- StringRef Category) const {
- return Loc.isValid() &&
- isBlacklistedFile(Mask, SM.getFilename(SM.getFileLoc(Loc)), Category);
-}
-
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 74c01fec6944..177cd3244458 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -362,8 +362,7 @@ static void addDataFlowSanitizerPass(const PassManagerBuilder &Builder,
const PassManagerBuilderWrapper &BuilderWrapper =
static_cast<const PassManagerBuilderWrapper&>(Builder);
const LangOptions &LangOpts = BuilderWrapper.getLangOpts();
- PM.add(
- createDataFlowSanitizerLegacyPassPass(LangOpts.SanitizerBlacklistFiles));
+ PM.add(createDataFlowSanitizerLegacyPassPass(LangOpts.NoSanitizeFiles));
}
static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
@@ -1132,7 +1131,7 @@ static void addSanitizers(const Triple &TargetTriple,
HWASanPass(SanitizerKind::KernelHWAddress, true);
if (LangOpts.Sanitize.has(SanitizerKind::DataFlow)) {
- MPM.addPass(DataFlowSanitizerPass(LangOpts.SanitizerBlacklistFiles));
+ MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
}
});
}
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index ba221dbbc83b..e687a0d25430 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2776,7 +2776,7 @@ void CodeGenFunction::EmitVTablePtrCheck(const CXXRecordDecl *RD,
}
std::string TypeName = RD->getQualifiedNameAsString();
- if (getContext().getSanitizerBlacklist().isBlacklistedType(M, TypeName))
+ if (getContext().getNoSanitizeList().containsType(M, TypeName))
return;
SanitizerScope SanScope(this);
@@ -2829,8 +2829,8 @@ bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) {
return false;
std::string TypeName = RD->getQualifiedNameAsString();
- return !getContext().getSanitizerBlacklist().isBlacklistedType(
- SanitizerKind::CFIVCall, TypeName);
+ return !getContext().getNoSanitizeList().containsType(SanitizerKind::CFIVCall,
+ TypeName);
}
llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
@@ -2852,8 +2852,8 @@ llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
std::string TypeName = RD->getQualifiedNameAsString();
if (SanOpts.has(SanitizerKind::CFIVCall) &&
- !getContext().getSanitizerBlacklist().isBlacklistedType(
- SanitizerKind::CFIVCall, TypeName)) {
+ !getContext().getNoSanitizeList().containsType(SanitizerKind::CFIVCall,
+ TypeName)) {
EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),
SanitizerHandler::CFICheckFail, {}, {});
}
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 3dbf4cc7cb97..c551901acc43 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -388,43 +388,43 @@ llvm::Function *CodeGenModule::CreateGlobalInitOrCleanUpFunction(
Fn->setDoesNotThrow();
if (getLangOpts().Sanitize.has(SanitizerKind::Address) &&
- !isInSanitizerBlacklist(SanitizerKind::Address, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::Address, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
if (getLangOpts().Sanitize.has(SanitizerKind::KernelAddress) &&
- !isInSanitizerBlacklist(SanitizerKind::KernelAddress, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::KernelAddress, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
if (getLangOpts().Sanitize.has(SanitizerKind::HWAddress) &&
- !isInSanitizerBlacklist(SanitizerKind::HWAddress, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::HWAddress, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
if (getLangOpts().Sanitize.has(SanitizerKind::KernelHWAddress) &&
- !isInSanitizerBlacklist(SanitizerKind::KernelHWAddress, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::KernelHWAddress, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
if (getLangOpts().Sanitize.has(SanitizerKind::MemTag) &&
- !isInSanitizerBlacklist(SanitizerKind::MemTag, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::MemTag, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
if (getLangOpts().Sanitize.has(SanitizerKind::Thread) &&
- !isInSanitizerBlacklist(SanitizerKind::Thread, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::Thread, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SanitizeThread);
if (getLangOpts().Sanitize.has(SanitizerKind::Memory) &&
- !isInSanitizerBlacklist(SanitizerKind::Memory, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::Memory, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
if (getLangOpts().Sanitize.has(SanitizerKind::KernelMemory) &&
- !isInSanitizerBlacklist(SanitizerKind::KernelMemory, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::KernelMemory, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
if (getLangOpts().Sanitize.has(SanitizerKind::SafeStack) &&
- !isInSanitizerBlacklist(SanitizerKind::SafeStack, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::SafeStack, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::SafeStack);
if (getLangOpts().Sanitize.has(SanitizerKind::ShadowCallStack) &&
- !isInSanitizerBlacklist(SanitizerKind::ShadowCallStack, Fn, Loc))
+ !isInNoSanitizeList(SanitizerKind::ShadowCallStack, Fn, Loc))
Fn->addFnAttr(llvm::Attribute::ShadowCallStack);
return Fn;
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index a3f90449bb4c..05c553f22d60 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -826,9 +826,9 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc,
CGM.getCXXABI().getMangleContext().mangleCXXRTTI(Ty.getUnqualifiedType(),
Out);
- // Blacklist based on the mangled type.
- if (!CGM.getContext().getSanitizerBlacklist().isBlacklistedType(
- SanitizerKind::Vptr, Out.str())) {
+ // Contained in NoSanitizeList based on the mangled type.
+ if (!CGM.getContext().getNoSanitizeList().containsType(SanitizerKind::Vptr,
+ Out.str())) {
llvm::hash_code TypeHash = hash_value(Out.str());
// Load the vptr, and compute hash_16_bytes(TypeHash, vptr).
@@ -3389,7 +3389,7 @@ void CodeGenFunction::EmitCfiCheckFail() {
StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args,
SourceLocation());
- // This function should not be affected by blacklist. This function does
+ // This function is not affected by NoSanitizeList. This function does
// not have a source location, but "src:*" would still apply. Revert any
// changes to SanOpts made in StartFunction.
SanOpts = CGM.getLangOpts().Sanitize;
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index f552b27fee5e..5888866b2546 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -711,14 +711,14 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
CurFnInfo = &FnInfo;
assert(CurFn->isDeclaration() && "Function already has body?");
- // If this function has been blacklisted for any of the enabled sanitizers,
+ // If this function is ignored for any of the enabled sanitizers,
// disable the sanitizer for the function.
do {
#define SANITIZER(NAME, ID) \
if (SanOpts.empty()) \
break; \
if (SanOpts.has(SanitizerKind::ID)) \
- if (CGM.isInSanitizerBlacklist(SanitizerKind::ID, Fn, Loc)) \
+ if (CGM.isInNoSanitizeList(SanitizerKind::ID, Fn, Loc)) \
SanOpts.set(SanitizerKind::ID, false);
#include "clang/Basic/Sanitizers.def"
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index ff36d5529d4c..d568e3d7095c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2459,29 +2459,28 @@ void CodeGenModule::AddGlobalAnnotations(const ValueDecl *D,
Annotations.push_back(EmitAnnotateAttr(GV, I, D->getLocation()));
}
-bool CodeGenModule::isInSanitizerBlacklist(SanitizerMask Kind,
- llvm::Function *Fn,
- SourceLocation Loc) const {
- const auto &SanitizerBL = getContext().getSanitizerBlacklist();
- // Blacklist by function name.
- if (SanitizerBL.isBlacklistedFunction(Kind, Fn->getName()))
+bool CodeGenModule::isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn,
+ SourceLocation Loc) const {
+ const auto &NoSanitizeL = getContext().getNoSanitizeList();
+ // NoSanitize by function name.
+ if (NoSanitizeL.containsFunction(Kind, Fn->getName()))
return true;
- // Blacklist by location.
+ // NoSanitize by location.
if (Loc.isValid())
- return SanitizerBL.isBlacklistedLocation(Kind, Loc);
+ return NoSanitizeL.containsLocation(Kind, Loc);
// If location is unknown, this may be a compiler-generated function. Assume
// it's located in the main file.
auto &SM = Context.getSourceManager();
if (const auto *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
- return SanitizerBL.isBlacklistedFile(Kind, MainFile->getName());
+ return NoSanitizeL.containsFile(Kind, MainFile->getName());
}
return false;
}
-bool CodeGenModule::isInSanitizerBlacklist(llvm::GlobalVariable *GV,
- SourceLocation Loc, QualType Ty,
- StringRef Category) const {
- // For now globals can be blacklisted only in ASan and KASan.
+bool CodeGenModule::isInNoSanitizeList(llvm::GlobalVariable *GV,
+ SourceLocation Loc, QualType Ty,
+ StringRef Category) const {
+ // For now globals can be ignored only in ASan and KASan.
const SanitizerMask EnabledAsanMask =
LangOpts.Sanitize.Mask &
(SanitizerKind::Address | SanitizerKind::KernelAddress |
@@ -2489,22 +2488,22 @@ bool CodeGenModule::isInSanitizerBlacklist(llvm::GlobalVariable *GV,
SanitizerKind::MemTag);
if (!EnabledAsanMask)
return false;
- const auto &SanitizerBL = getContext().getSanitizerBlacklist();
- if (SanitizerBL.isBlacklistedGlobal(EnabledAsanMask, GV->getName(), Category))
+ const auto &NoSanitizeL = getContext().getNoSanitizeList();
+ if (NoSanitizeL.containsGlobal(EnabledAsanMask, GV->getName(), Category))
return true;
- if (SanitizerBL.isBlacklistedLocation(EnabledAsanMask, Loc, Category))
+ if (NoSanitizeL.containsLocation(EnabledAsanMask, Loc, Category))
return true;
// Check global type.
if (!Ty.isNull()) {
// Drill down the array types: if global variable of a fixed type is
- // blacklisted, we also don't instrument arrays of them.
+ // not sanitized, we also don't instrument arrays of them.
while (auto AT = dyn_cast<ArrayType>(Ty.getTypePtr()))
Ty = AT->getElementType();
Ty = Ty.getCanonicalType().getUnqualifiedType();
- // We allow to blacklist only record types (classes, structs etc.)
+ // Only record types (classes, structs etc.) are ignored.
if (Ty->isRecordType()) {
std::string TypeStr = Ty.getAsString(getContext().getPrintingPolicy());
- if (SanitizerBL.isBlacklistedType(EnabledAsanMask, TypeStr, Category))
+ if (NoSanitizeL.containsType(EnabledAsanMask, TypeStr, Category))
return true;
}
}
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 4ff7deb70636..64118746f116 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -25,7 +25,7 @@
#include "clang/Basic/ABI.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Module.h"
-#include "clang/Basic/SanitizerBlacklist.h"
+#include "clang/Basic/NoSanitizeList.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/XRayLists.h"
#include "llvm/ADT/DenseMap.h"
@@ -1267,12 +1267,11 @@ class CodeGenModule : public CodeGenTypeCache {
/// annotations are emitted during finalization of the LLVM code.
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
- bool isInSanitizerBlacklist(SanitizerMask Kind, llvm::Function *Fn,
- SourceLocation Loc) const;
+ bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn,
+ SourceLocation Loc) const;
- bool isInSanitizerBlacklist(llvm::GlobalVariable *GV, SourceLocation Loc,
- QualType Ty,
- StringRef Category = StringRef()) const;
+ bool isInNoSanitizeList(llvm::GlobalVariable *GV, SourceLocation Loc,
+ QualType Ty, StringRef Category = StringRef()) const;
/// Imbue XRay attributes to a function, applying the always/never attribute
/// lists in the process. Returns true if we did imbue attributes this way,
diff --git a/clang/lib/CodeGen/SanitizerMetadata.cpp b/clang/lib/CodeGen/SanitizerMetadata.cpp
index cdf83370c41f..009965a36c39 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -1,4 +1,4 @@
-//===--- SanitizerMetadata.cpp - Blacklist for sanitizers -----------------===//
+//===--- SanitizerMetadata.cpp - Ignored entities for sanitizers ----------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,15 +34,15 @@ void SanitizerMetadata::reportGlobalToASan(llvm::GlobalVariable *GV,
bool IsExcluded) {
if (!isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
return;
- IsDynInit &= !CGM.isInSanitizerBlacklist(GV, Loc, Ty, "init");
- IsExcluded |= CGM.isInSanitizerBlacklist(GV, Loc, Ty);
+ IsDynInit &= !CGM.isInNoSanitizeList(GV, Loc, Ty, "init");
+ IsExcluded |= CGM.isInNoSanitizeList(GV, Loc, Ty);
llvm::Metadata *LocDescr = nullptr;
llvm::Metadata *GlobalName = nullptr;
llvm::LLVMContext &VMContext = CGM.getLLVMContext();
if (!IsExcluded) {
- // Don't generate source location and global name if it is blacklisted -
- // it won't be instrumented anyway.
+ // Don't generate source location and global name if it is on
+ // the NoSanitizeList - it won't be instrumented anyway.
LocDescr = getLocationMetadata(Loc);
if (!Name.empty())
GlobalName = llvm::MDString::get(VMContext, Name);
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index a870940ac110..92fb8ce8dc09 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3607,7 +3607,7 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
GenerateArg(Args, OPT_fsanitize_EQ, Sanitizer, SA);
// Conflating '-fsanitize-system-blacklist' and '-fsanitize-blacklist'.
- for (const std::string &F : Opts.SanitizerBlacklistFiles)
+ for (const std::string &F : Opts.NoSanitizeFiles)
GenerateArg(Args, OPT_fsanitize_blacklist, F, SA);
if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver3_8)
@@ -4006,12 +4006,11 @@ bool CompilerInvocation::ParseLangArgsImpl(LangOptions &Opts, ArgList &Args,
// Parse -fsanitize= arguments.
parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
Diags, Opts.Sanitize);
- Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
+ Opts.NoSanitizeFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
std::vector<std::string> systemBlacklists =
Args.getAllArgValues(OPT_fsanitize_system_blacklist);
- Opts.SanitizerBlacklistFiles.insert(Opts.SanitizerBlacklistFiles.end(),
- systemBlacklists.begin(),
- systemBlacklists.end());
+ Opts.NoSanitizeFiles.insert(Opts.NoSanitizeFiles.end(),
+ systemBlacklists.begin(), systemBlacklists.end());
if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) {
Opts.setClangABICompat(LangOptions::ClangABI::Latest);
More information about the cfe-commits
mailing list