================ @@ -1832,6 +1832,33 @@ static ExprResult BuiltinLaunder(Sema &S, CallExpr *TheCall) { return TheCall; } +static ExprResult BuiltinIsWithinLifetime(Sema &S, CallExpr *TheCall) { + if (checkArgCount(S, TheCall, 1)) + return ExprError(); + + ExprResult Arg = S.DefaultFunctionArrayLvalueConversion(TheCall->getArg(0)); + if (Arg.isInvalid()) + return ExprError(); + QualType ParamTy = Arg.get()->getType(); + TheCall->setArg(0, Arg.get()); + TheCall->setType(S.Context.BoolTy); + + // A call to this function is always ill-formed if the type is not a pointer + // to an object type. There is no Mandates: to that effect, so we can only + // issue an error if it is actually evaluated as part of a constant evaluation + // (e.g., `false ? true : ---------------- cor3ntin wrote:
I think this is not quite true. The function is defined as ` consteval bool is_within_lifetime(const T* p) noexcept;` The const does _a lot_ of heavy lifting there. https://compiler-explorer.com/z/hdvfWEbYj The const reject function pointer types (https://eel.is/c++draft/conv.qual#5) So I think this should be handled there, rather than in the constexpr evaluator https://github.com/llvm/llvm-project/pull/91895 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits