[clang] [clang][bytecode] Fix 'if consteval' in non-constant contexts (PR #104707)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 20 07:43:18 PDT 2024
================
@@ -4368,8 +4363,19 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) {
if (!visitDeclStmt(CondDecl))
return false;
- if (!this->visitBool(IS->getCond()))
- return false;
+ // Compile condition.
+ if (IS->isNonNegatedConsteval()) {
+ if (!this->emitIsConstantContext(IS))
+ return false;
+ } else if (IS->isNegatedConsteval()) {
+ if (!this->emitIsConstantContext(IS))
+ return false;
+ if (!this->emitInv(IS))
+ return false;
+ } else {
+ if (!this->visitBool(IS->getCond()))
+ return false;
+ }
----------------
cor3ntin wrote:
I guess my question is whether doing that would prevent us to evaluate/create bytecode for statements for which the non-taken branch has things the byte code interpreter can't compile yet.
Including non-constexpr function calls, UB, goto, coroutines, exceptions, asm blocks, builtins, simd, threads, etc etc
https://github.com/llvm/llvm-project/pull/104707
More information about the cfe-commits
mailing list