[clang] f32ad57 - [NFC] Move part of SanitizerMetadata into private method
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 7 14:09:06 PDT 2022
Author: Vitaly Buka
Date: 2022-06-07T14:08:43-07:00
New Revision: f32ad5703e83435522df18b862979b83cc5bf7c3
URL: https://github.com/llvm/llvm-project/commit/f32ad5703e83435522df18b862979b83cc5bf7c3
DIFF: https://github.com/llvm/llvm-project/commit/f32ad5703e83435522df18b862979b83cc5bf7c3.diff
LOG: [NFC] Move part of SanitizerMetadata into private method
Added:
Modified:
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/lib/CodeGen/SanitizerMetadata.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 1d6972892958..21f721963991 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -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);
diff --git a/clang/lib/CodeGen/SanitizerMetadata.cpp b/clang/lib/CodeGen/SanitizerMetadata.cpp
index cae5e79e724e..5e094ec4c505 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -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.
diff --git a/clang/lib/CodeGen/SanitizerMetadata.h b/clang/lib/CodeGen/SanitizerMetadata.h
index 753b32c4a0fc..a2290fa290f5 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.h
+++ b/clang/lib/CodeGen/SanitizerMetadata.h
@@ -40,12 +40,14 @@ class SanitizerMetadata {
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
More information about the cfe-commits
mailing list