18using namespace CodeGen;
23 return SS.
hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress |
24 SanitizerKind::HWAddress | SanitizerKind::MemTag |
29 if (Mask & (SanitizerKind::Address | SanitizerKind::KernelAddress))
30 Mask |= SanitizerKind::Address | SanitizerKind::KernelAddress;
47 FsanitizeArgument.
Mask};
49 llvm::GlobalVariable::SanitizerMetadata Meta;
50 if (GV->hasSanitizerMetadata())
51 Meta = GV->getSanitizerMetadata();
53 Meta.NoAddress |= NoSanitizeAttrSet.
hasOneOf(SanitizerKind::Address);
55 FsanitizeArgument.
Mask & SanitizerKind::Address, GV,
Loc, Ty);
57 Meta.NoHWAddress |= NoSanitizeAttrSet.
hasOneOf(SanitizerKind::HWAddress);
59 FsanitizeArgument.
Mask & SanitizerKind::HWAddress, GV,
Loc, Ty);
62 static_cast<bool>(FsanitizeArgument.
Mask & SanitizerKind::MemtagGlobals);
63 Meta.Memtag &= !NoSanitizeAttrSet.
hasOneOf(SanitizerKind::MemTag);
65 FsanitizeArgument.
Mask & SanitizerKind::MemTag, GV,
Loc, Ty);
67 Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
68 FsanitizeArgument.
has(SanitizerKind::Address) &&
70 SanitizerKind::KernelAddress,
73 GV->setSanitizerMetadata(Meta);
76 NoSanitizeAttrMask & SanitizerKind::Type)
83 llvm::Metadata *GlobalMetadata[] = {llvm::ConstantAsMetadata::get(GV),
87 if (llvm::MDNode::getIfExists(CGM.
getLLVMContext(), GlobalMetadata))
90 llvm::MDNode *ThisGlobal =
92 llvm::NamedMDNode *TysanGlobals =
93 CGM.
getModule().getOrInsertNamedMetadata(
"llvm.tysan.globals");
94 TysanGlobals->addOperand(ThisGlobal);
101 std::string QualName;
102 llvm::raw_string_ostream OS(QualName);
103 D.printQualifiedName(OS);
105 auto getNoSanitizeMask = [](
const VarDecl &
D) {
106 if (
D.
hasAttr<DisableSanitizerInstrumentationAttr>())
107 return SanitizerKind::All;
111 NoSanitizeMask |=
Attr->getMask();
115 if (
D.hasExternalStorage() ||
D.getType()->isIncompleteType())
116 NoSanitizeMask |= SanitizerKind::Type;
118 return NoSanitizeMask;
C Language Family Type Representation.
Attr - This represents one attribute.
This class organizes the cross-function state that is used while generating LLVM code.
llvm::Module & getModule() const
bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn, SourceLocation Loc) const
const LangOptions & getLangOpts() const
ASTContext & getContext() const
llvm::MDNode * getTBAATypeInfo(QualType QTy)
getTBAATypeInfo - Get metadata used to describe accesses to objects of the given type.
llvm::LLVMContext & getLLVMContext()
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
SanitizerSet Sanitize
Set of enabled sanitizers.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Encodes a location in the source.
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
SanitizerMask Mask
Bitmask of enabled sanitizers.
bool hasOneOf(SanitizerMask K) const
Check if one or more sanitizers are enabled.