================ @@ -1549,6 +1549,54 @@ bool Sema::checkConstantPointerAuthKey(Expr *Arg, unsigned &Result) { return false; } +bool Sema::checkPointerAuthDiscriminatorArg(Expr *Arg, + PointerAuthDiscArgKind Kind, + unsigned &IntVal) { + if (!Arg) { + IntVal = 0; + return true; + } + + std::optional<llvm::APSInt> Result = Arg->getIntegerConstantExpr(Context); + if (!Result) { + Diag(Arg->getExprLoc(), diag::err_ptrauth_arg_not_ice); + return false; + } + + unsigned Max; + bool IsAddrDiscArg = false; + + switch (Kind) { + case PADAK_AddrDiscPtrAuth: + Max = 1; + IsAddrDiscArg = true; + break; + case PADAK_ExtraDiscPtrAuth: + Max = PointerAuthQualifier::MaxDiscriminator; + break; + }; + + if (*Result < 0 || *Result > Max) { + llvm::SmallString<32> Value; + { + llvm::raw_svector_ostream str(Value); + str << *Result; + } + ---------------- AaronBallman wrote:
I'm pretty sure you can pass an `APSInt` in directly to the call to `Diag()`, but if not, you can get the integer value from the object and pass that in. Let's avoid ostreams if we can. https://github.com/llvm/llvm-project/pull/100830 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits