[PATCH] D140803: [clang][Interp] Implement C++ Range-for loops
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 18 10:32:20 PST 2023
aaron.ballman added inline comments.
================
Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:404-409
+ if (Cond) {
+ if (!this->visitBool(Cond))
+ return false;
+ if (!this->jumpFalse(EndLabel))
+ return false;
+ }
----------------
Under what circumstances is there not a condition for a range-based for loop?
================
Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:418-419
+ this->emitLabel(IncLabel);
+ if (Inc && !this->discard(Inc))
+ return false;
+ if (!this->jump(CondLabel))
----------------
Under what circumstances is there not an increment?
================
Comment at: clang/test/AST/Interp/loops.cpp:278
+
+namespace RangeForLoop {
+ constexpr int localArray() {
----------------
You should also add failure tests where the range-based for loop is not valid in a constant expression. Especially interesting cases would be ones involving lifetime problems, such as: https://godbolt.org/z/3EE7f8rdE
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140803/new/
https://reviews.llvm.org/D140803
More information about the cfe-commits
mailing list