[clang] [clang][Interp] Only evaluate the source array initialization of an `ArrayInitLoopExpr` once (PR #68039)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 2 14:24:34 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 55d8f0cd31311ed3ebc85bef2c9b5cfca1579076 3724f695e7699840998d8af16a60f02f90f64b95 -- clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/lib/AST/Interp/ByteCodeExprGen.h clang/test/AST/Interp/arrays.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 27848e7bb732..bcca8a3a87d0 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -828,12 +828,12 @@ bool ByteCodeExprGen<Emitter>::VisitArrayInitLoopExpr(
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
- if(OpaqueExprs.contains(E))
+ if (OpaqueExprs.contains(E))
return this->emitGetLocal(*classify(E), OpaqueExprs[E], E);
if (Initializing)
return this->visitInitializer(E->getSourceExpr());
-
+
return this->visit(E->getSourceExpr());
}
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 0e69eee128f4..1a66a8b76dcb 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -484,19 +484,21 @@ template <class Emitter> class StoredOpaqueValueScope final {
public:
StoredOpaqueValueScope(ByteCodeExprGen<Emitter> *Ctx) : Ctx(Ctx) {}
- bool VisitAndStoreOpaqueValue(const OpaqueValueExpr* Ove) {
+ bool VisitAndStoreOpaqueValue(const OpaqueValueExpr *Ove) {
assert(Ove && "OpaqueValueExpr is a nullptr!");
- assert(!Ctx->OpaqueExprs.contains(Ove) && "OpaqueValueExpr already stored!");
+ assert(!Ctx->OpaqueExprs.contains(Ove) &&
+ "OpaqueValueExpr already stored!");
std::optional<PrimType> CommonTy = Ctx->classify(Ove);
- std::optional<unsigned> LocalIndex = Ctx->allocateLocalPrimitive(Ove, *CommonTy, Ove->getType().isConstQualified());
+ std::optional<unsigned> LocalIndex = Ctx->allocateLocalPrimitive(
+ Ove, *CommonTy, Ove->getType().isConstQualified());
if (!LocalIndex)
return false;
if (!Ctx->visit(Ove))
return false;
- if(!Ctx->emitSetLocal(*CommonTy, *LocalIndex, Ove))
+ if (!Ctx->emitSetLocal(*CommonTy, *LocalIndex, Ove))
return false;
Ctx->OpaqueExprs.insert({Ove, *LocalIndex});
@@ -506,13 +508,13 @@ public:
}
~StoredOpaqueValueScope() {
- for(const auto *SV : StoredValues)
+ for (const auto *SV : StoredValues)
Ctx->OpaqueExprs.erase(SV);
}
private:
ByteCodeExprGen<Emitter> *Ctx;
- std::vector<const OpaqueValueExpr*> StoredValues;
+ std::vector<const OpaqueValueExpr *> StoredValues;
};
} // namespace interp
``````````
</details>
https://github.com/llvm/llvm-project/pull/68039
More information about the cfe-commits
mailing list