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

Marco Elver via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 18 17:47:12 PST 2025


================
@@ -3587,6 +3587,30 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
     }
     break;
   }
+
+  case Builtin::BI__builtin_allow_sanitize_check: {
+    Expr *Arg = TheCall->getArg(0);
+    // Check if the argument is a string literal.
+    const StringLiteral *SanitizerName =
+        dyn_cast<StringLiteral>(Arg->IgnoreParenImpCasts());
----------------
melver wrote:

I fear that GCC folks won't like that, as it's a bit too magical, because that builtin will have too many different semantics depending on its inputs (we really want GCC to implement it too, otherwise it's unlikely this will get used).

Currently `__builtin_allow_runtime_check()` semantics is only for denoting checking in hot/cold code. If we expand its semantics to depend on sanitizer names, I think it will become too complex. In general I was also hesitating using strings to disambiguate or introduce one builtin per sanitizer, but keeping the precedent of mapping the strings to `no_sanitize(string)` is probably good here.

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


More information about the llvm-branch-commits mailing list