[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 15 18:31:22 PST 2024
================
@@ -437,6 +442,16 @@ namespace {
MostDerivedArraySize = 2;
MostDerivedPathLength = Entries.size();
}
+ void addVectorUnchecked(QualType EltTy, uint64_t Size, uint64_t Idx) {
+ Entries.push_back(PathEntry::ArrayIndex(Idx));
+
+ // This is technically a most-derived object, though in practice this
+ // is unlikely to matter.
+ MostDerivedType = EltTy;
+ MostDerivedIsArrayElement = true;
+ MostDerivedArraySize = Size;
----------------
sethp wrote:
I'm not sure about this: it seems to indicate that an expression like `&V[0]` ought to be valid, but it's often not possible to take a pointer to a vector element (i.e. when they're living in a vector register).
That said, I see it's what the `Complex` type is doing, and I whose elements I think are also not individually addressable, so :shrug:
https://github.com/llvm/llvm-project/pull/72607
More information about the cfe-commits
mailing list