[clang] [llvm] [Clang] Add __builtin_allow_sanitize_check() (PR #172030)

Marco Elver via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 5 12:42:34 PST 2026


melver wrote:

> (Response delayed because I was off last two weeks.)
> 
> I don't think the name of the intrinsic makes sense. Can we just call it `__builtin_is_sanitizer_enabled()`?

It was meant to be consistent with the exsiting `__builtin_allow_runtime_check`.

One point is that "enabled" is easy to be misunderstood: the sanitizer *is* enabled at the TU level, but might be disabled on a per-function basis.

We have `__SANITIZE_{ADDRESS,THREAD,MEMORY}__` pre-processor macros to check the per-TU state. However, that doesn't help checking per-function enablement state.

The "allow check" name makes no claims about it being enabled or disabled, only if an explicit check is allowed where the builtin is used.

But maybe I'm overthinking it. I don't mind either way - if you want the name changed, we'll revert.

Preferences?

> I think I'd like a Discourse post so people are aware we've added this. I'm not expecting any significant changes to the design, though, because there's basically only one way to do this.

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


More information about the cfe-commits mailing list