[llvm-branch-commits] [clang] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)
Vitaly Buka via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Apr 10 14:28:20 PDT 2024
================
@@ -3233,6 +3233,17 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
if (BuiltinCountZeroBitsGeneric(*this, TheCall))
return ExprError();
break;
+
+ case Builtin::BI__builtin_allow_runtime_check: {
+ Expr *Arg = TheCall->getArg(0);
+ // Check if the argument is a string literal.
+ if (!isa<StringLiteral>(Arg->IgnoreParenImpCasts())) {
----------------
vitalybuka wrote:
My interest is in using this feature to implement `assert` like macros which will be enabled in cold code, and optimized out in hot. E.g. MY_ASSERT1, MY_ASSERT2...
Each macro can provide own kind as literal. Number of different kinds is supposed to be limited. So literal looks enough for me.
We can relax in the future, restricting could be harder.
https://github.com/llvm/llvm-project/pull/87568
More information about the llvm-branch-commits
mailing list