From: Vitaly Buka Date: Tue, 7 Jun 2022 04:43:47 +0000 (-0700) Subject: [NFC] Move part of SanitizerMetadata into private method X-Git-Tag: upstream/15.0.7~5599 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f32ad5703e83435522df18b862979b83cc5bf7c3;p=platform%2Fupstream%2Fllvm.git [NFC] Move part of SanitizerMetadata into private method --- diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1d69728..21f7219 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), "", - QualType()); + SanitizerMD->reportGlobal(GV, S->getStrTokenLoc(0), ""); return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV), GV->getValueType(), Alignment); diff --git a/clang/lib/CodeGen/SanitizerMetadata.cpp b/clang/lib/CodeGen/SanitizerMetadata.cpp index cae5e79..5e094ec 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 753b32c..a2290fa 100644 --- a/clang/lib/CodeGen/SanitizerMetadata.h +++ b/clang/lib/CodeGen/SanitizerMetadata.h @@ -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