[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 16 22:05:14 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;
----------------
arsenm wrote:

I think accessing individual fields should be OK. Taking the address of a vector element feels wrong, but I haven't thought too deeply about it 

https://github.com/llvm/llvm-project/pull/72607


More information about the cfe-commits mailing list