Introduce a SanitizerKind enum to LangOptions.
Use the bitmask to store the set of enabled sanitizers instead of a bitfield. On the negative side, it makes syntax for querying the set of enabled sanitizers a bit more clunky. On the positive side, we will be able to use SanitizerKind to eventually implement the new semantics for -fsanitize-recover= flag, that would allow us to make some sanitizers recoverable, and some non-recoverable. No functionality change. llvm-svn: 221558
This commit is contained in:
@@ -120,7 +120,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
|
||||
createCUDARuntime();
|
||||
|
||||
// Enable TBAA unless it's suppressed. ThreadSanitizer needs TBAA even at O0.
|
||||
if (LangOpts.Sanitize.Thread ||
|
||||
if (LangOpts.Sanitize.has(SanitizerKind::Thread) ||
|
||||
(!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0))
|
||||
TBAA = new CodeGenTBAA(Context, VMContext, CodeGenOpts, getLangOpts(),
|
||||
getCXXABI().getMangleContext());
|
||||
@@ -743,13 +743,16 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
|
||||
if (!isInSanitizerBlacklist(F, D->getLocation())) {
|
||||
// When AddressSanitizer is enabled, set SanitizeAddress attribute
|
||||
// unless __attribute__((no_sanitize_address)) is used.
|
||||
if (LangOpts.Sanitize.Address && !D->hasAttr<NoSanitizeAddressAttr>())
|
||||
if (LangOpts.Sanitize.has(SanitizerKind::Address) &&
|
||||
!D->hasAttr<NoSanitizeAddressAttr>())
|
||||
B.addAttribute(llvm::Attribute::SanitizeAddress);
|
||||
// Same for ThreadSanitizer and __attribute__((no_sanitize_thread))
|
||||
if (LangOpts.Sanitize.Thread && !D->hasAttr<NoSanitizeThreadAttr>())
|
||||
if (LangOpts.Sanitize.has(SanitizerKind::Thread) &&
|
||||
!D->hasAttr<NoSanitizeThreadAttr>())
|
||||
B.addAttribute(llvm::Attribute::SanitizeThread);
|
||||
// Same for MemorySanitizer and __attribute__((no_sanitize_memory))
|
||||
if (LangOpts.Sanitize.Memory && !D->hasAttr<NoSanitizeMemoryAttr>())
|
||||
if (LangOpts.Sanitize.has(SanitizerKind::Memory) &&
|
||||
!D->hasAttr<NoSanitizeMemoryAttr>())
|
||||
B.addAttribute(llvm::Attribute::SanitizeMemory);
|
||||
}
|
||||
|
||||
@@ -1190,7 +1193,7 @@ bool CodeGenModule::isInSanitizerBlacklist(llvm::GlobalVariable *GV,
|
||||
SourceLocation Loc, QualType Ty,
|
||||
StringRef Category) const {
|
||||
// For now globals can be blacklisted only in ASan.
|
||||
if (!LangOpts.Sanitize.Address)
|
||||
if (!LangOpts.Sanitize.has(SanitizerKind::Address))
|
||||
return false;
|
||||
const auto &SanitizerBL = getContext().getSanitizerBlacklist();
|
||||
if (SanitizerBL.isBlacklistedGlobal(GV->getName(), Category))
|
||||
@@ -2819,7 +2822,8 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
|
||||
// Mangle the string literal if the ABI allows for it. However, we cannot
|
||||
// do this if we are compiling with ASan or -fwritable-strings because they
|
||||
// rely on strings having normal linkage.
|
||||
if (!LangOpts.WritableStrings && !LangOpts.Sanitize.Address &&
|
||||
if (!LangOpts.WritableStrings &&
|
||||
!LangOpts.Sanitize.has(SanitizerKind::Address) &&
|
||||
getCXXABI().getMangleContext().shouldMangleStringLiteral(S)) {
|
||||
llvm::raw_svector_ostream Out(MangledNameBuffer);
|
||||
getCXXABI().getMangleContext().mangleStringLiteral(S, Out);
|
||||
|
||||
Reference in New Issue
Block a user