Pol Marcet =?utf-8?q?Sardà ?= <polmarcetsa...@gmail.com>, Pol Marcet =?utf-8?q?Sardà ?= <polmarcetsa...@gmail.com>,Pol M <polmarcetsa...@gmail.com> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/76...@github.com>
================ @@ -10895,6 +10899,132 @@ bool VectorExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { return Success(APValue(ResultElements.data(), ResultElements.size()), E); } +static bool EvaluateVectorOrLValue(APValue &Result, EvalInfo &Info, + const Expr *E, const QualType &Type) { + if (!Evaluate(Result, Info, E)) + return false; + + if (Result.isLValue()) { + // Source of the data is an lvalue; Manually handle the lvalue as if + // it was an rvalue to get the current APValue. + LValue LValueFound; + LValueFound.setFrom(Info.Ctx, Result); + if (!handleLValueToRValueConversion(Info, E, Type, LValueFound, Result)) + return false; + } + + return Result.isVector(); +} + +static bool handleVectorConversion(EvalInfo &Info, const FPOptions FPO, + const Expr *E, QualType SourceTy, + QualType DestTy, APValue const &Original, + APValue &Result) { + if (SourceTy->isIntegerType()) { + if (DestTy->isRealFloatingType()) { + Result = APValue(APFloat(0.0)); + return HandleIntToFloatCast(Info, E, FPO, SourceTy, Original.getInt(), + DestTy, Result.getFloat()); ---------------- sethp wrote: This is probably my own inadequate understanding of C++, but I feel like the pattern I see elsewhere in the evaluator would look more like this here: ```c++ APFloat Float; if (!HandleIntToFloatCast(Info, E, FPO, SourceTy, Original.getInt(), DestTy, Float); return false; Result = APValue(Float); return true; ``` Is the difference meaningful, do you think? https://github.com/llvm/llvm-project/pull/76615 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits