[NFC] Move part of SanitizerMetadata into private method
authorVitaly Buka <vitalybuka@google.com>
Tue, 7 Jun 2022 04:43:47 +0000 (21:43 -0700)
committerVitaly Buka <vitalybuka@google.com>
Tue, 7 Jun 2022 21:08:43 +0000 (14:08 -0700)
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/lib/CodeGen/SanitizerMetadata.h

index 1d69728..21f7219 100644 (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);
index cae5e79..5e094ec 100644 (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.
index 753b32c..a2290fa 100644 (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