[clang] [clang][Interp] Only evaluate the source array initialization of an `ArrayInitLoopExpr` once (PR #68039)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 18 23:20:03 PDT 2023


================
@@ -847,7 +845,33 @@ template <class Emitter>
 bool ByteCodeExprGen<Emitter>::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
   if (Initializing)
     return this->visitInitializer(E->getSourceExpr());
-  return this->visit(E->getSourceExpr());
+
+  PrimType CacheVariableTy = classify(E).value_or(PT_Ptr);
+  if (OpaqueExprs.contains(E))
+    return this->emitGetLocal(CacheVariableTy, OpaqueExprs[E], E);
----------------
tbaederr wrote:

```suggestion
  if (auto It = OpaqueExprs.find(E); It != OpaqueExprs.end())
    return this->emitGetLocal(CacheVariableTy, *It, E);
```

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


More information about the cfe-commits mailing list