[NFC] Move part of SanitizerMetadata into private method

This commit is contained in:
Vitaly Buka 2022-06-06 21:43:47 -07:00
parent 5d9de5f446
commit f32ad5703e
3 changed files with 13 additions and 6 deletions

View File

@ -5677,8 +5677,7 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
if (Entry)
*Entry = GV;
SanitizerMD->reportGlobal(GV, S->getStrTokenLoc(0), "<string literal>",
QualType());
SanitizerMD->reportGlobal(GV, S->getStrTokenLoc(0), "<string literal>");
return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV),
GV->getValueType(), Alignment);

View File

@ -32,8 +32,6 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
SourceLocation Loc, StringRef Name,
QualType Ty, bool IsDynInit,
bool IsExcluded) {
if (!isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
return;
IsDynInit &= !CGM.isInNoSanitizeList(GV, Loc, Ty, "init");
IsExcluded |= CGM.isInNoSanitizeList(GV, Loc, Ty);
@ -79,6 +77,14 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
IsExcluded);
}
void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
SourceLocation Loc, StringRef Name,
QualType Ty, bool IsDynInit) {
if (!isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
return;
reportGlobal(GV, Loc, Name, Ty, IsDynInit, false);
}
void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable *GV) {
// For now, just make sure the global is not modified by the ASan
// instrumentation.

View File

@ -40,12 +40,14 @@ public:
void reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
bool IsDynInit = false);
void reportGlobal(llvm::GlobalVariable *GV, SourceLocation Loc,
StringRef Name, QualType Ty, bool IsDynInit = false,
bool IsExcluded = false);
StringRef Name, QualType Ty = {}, bool IsDynInit = false);
void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
void disableSanitizerForInstruction(llvm::Instruction *I);
private:
void reportGlobal(llvm::GlobalVariable *GV, SourceLocation Loc,
StringRef Name, QualType Ty, bool IsDynInit,
bool IsExcluded);
llvm::MDNode *getLocationMetadata(SourceLocation Loc);
};
} // end namespace CodeGen