[clang] d7df3f0 - [NFC] Exctract getNoSanitizeMask lambda

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 14:09:08 PDT 2022


Author: Vitaly Buka
Date: 2022-06-07T14:08:43-07:00
New Revision: d7df3f0a4b8dd089ade1805ab150efc5b1c84fe7

URL: https://github.com/llvm/llvm-project/commit/d7df3f0a4b8dd089ade1805ab150efc5b1c84fe7
DIFF: https://github.com/llvm/llvm-project/commit/d7df3f0a4b8dd089ade1805ab150efc5b1c84fe7.diff

LOG: [NFC] Exctract getNoSanitizeMask lambda

Added: 
    

Modified: 
    clang/lib/CodeGen/SanitizerMetadata.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 5e094ec4c505..8127e1519261 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -67,14 +67,18 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
   llvm::raw_string_ostream OS(QualName);
   D.printQualifiedName(OS);
 
-  bool IsExcluded = false;
-  for (auto Attr : D.specific_attrs<NoSanitizeAttr>())
-    if (Attr->getMask() & SanitizerKind::Address)
-      IsExcluded = true;
-  if (D.hasAttr<DisableSanitizerInstrumentationAttr>())
-    IsExcluded = true;
+  auto getNoSanitizeMask = [](const VarDecl &D) {
+    if (D.hasAttr<DisableSanitizerInstrumentationAttr>())
+      return SanitizerKind::All;
+
+    SanitizerMask NoSanitizeMask;
+    for (auto *Attr : D.specific_attrs<NoSanitizeAttr>())
+      NoSanitizeMask |= Attr->getMask();
+
+    return NoSanitizeMask;
+  };
   reportGlobal(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit,
-               IsExcluded);
+               SanitizerSet{getNoSanitizeMask(D)}.has(SanitizerKind::Address));
 }
 
 void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,


        


More information about the cfe-commits mailing list