[clang] [CIR] Initial support for sanitizer attributes (PR #220625)

Sirui Mu via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 07:14:00 PDT 2026


================
@@ -144,6 +144,15 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &mlirContext,
   theModule->setAttr(cir::CIRDialect::getIntTypeWidthAttrName(),
                      builder.getI32IntegerAttr(target.getIntWidth()));
 
+  llvm::SmallVector<cir::SanitizeKind> sanitizerKinds;
+  if (getLangOpts().Sanitize.has(SanitizerKind::Address))
----------------
Lancern wrote:

`SanitizerMask` is actually a `struct` with two private `uint64_t` for the bitmask:

https://github.com/llvm/llvm-project/blob/659faef7717be80c12e47604e61c01f2d7fc4975/clang/include/clang/Basic/Sanitizers.h#L34-L46

So a plain `static_cast` won't do the job easily. Is it a good idea to directly embed a `SanitizerMask` object into a CIR attribute?

https://github.com/llvm/llvm-project/pull/220625


More information about the cfe-commits mailing list