[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
Thu Oct 12 06:41:19 PDT 2023


================
@@ -827,6 +829,9 @@ bool ByteCodeExprGen<Emitter>::VisitArrayInitLoopExpr(
 
 template <class Emitter>
 bool ByteCodeExprGen<Emitter>::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
+  if (OpaqueExprs.contains(E))
+    return this->emitGetLocal(*classify(E), OpaqueExprs[E], E);
----------------
tbaederr wrote:

Can `E` be of  composite type? If so, we need to handle that. If not,  you can just use `classifyPrim` instead.

This code also potentially does two lookups. you should do `auto It = OpaqueExprs.find(E); It != OpaqueExprs.end()) {`

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


More information about the cfe-commits mailing list