[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 1 05:19:56 PST 2024
================
@@ -10895,6 +10899,138 @@ 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;
+ }
+ }
+
+ if (!Result.isVector()) {
+ return false;
+ }
+ return true;
----------------
RKSimon wrote:
Just use `return Result.isVector()` ?
https://github.com/llvm/llvm-project/pull/76615
More information about the cfe-commits
mailing list