================
@@ -1306,6 +1308,44 @@ interp__builtin_ptrauth_string_discriminator(InterpState
&S, CodePtr OpPC,
return true;
}
+static bool interp__builtin_infer_alloc_token(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const CallExpr *Call) {
+ const ASTContext &Ctx = S.getASTContext();
+ const uint64_t BitWidth = Ctx.getTypeSize(Ctx.getSizeType());
+ const auto Mode =
+ Ctx.getLangOpts().AllocTokenMode.value_or(llvm::DefaultAllocTokenMode);
+ const uint64_t MaxTokens =
+ Ctx.getLangOpts().AllocTokenMax.value_or(~0ULL >> (64 - BitWidth));
+
+ // We do not read any of the arguments; discard them.
+ for (int I = Call->getNumArgs() - 1; I >= 0; --I)
+ discard(S.Stk, *S.getContext().classify(Call->getArg(I)));
+
+ // Note: Type inference from a surrounding cast is not supported in
+ // constexpr evaluation.
+ QualType AllocType = infer_alloc::inferPossibleType(Call, Ctx, nullptr);
+ if (AllocType.isNull()) {
+ S.CCEDiag(Call) << "could not infer allocation type";
+ return false;
+ }
+
+ auto ATMD = infer_alloc::getAllocTokenMetadata(AllocType, Ctx);
+ if (!ATMD) {
+ S.CCEDiag(Call) << "could not get token metadata for type";
----------------
melver wrote:
Thanks - adding it.
https://github.com/llvm/llvm-project/pull/163639
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits