Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4974,20 +4974,35 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) {
LabelTy LabelEnd = this->getLabel();
if (!this->jumpFalse(LabelElse))
return false;
if (!visitStmt(IS->getThen()))
return false;
{
LocalScope<Emitter> ThenScope(this);
if (!visitStmt(IS->getThen()))
return false;
if (!ThenScope.destroyLocals())
return false;
}
if (!this->jump(LabelEnd))
return false;
this->emitLabel(LabelElse);
if (!visitStmt(Else))
return false;
{
LocalScope<Emitter> ElseScope(this);
if (!visitStmt(Else))
return false;
if (!ElseScope.destroyLocals())
return false;
}
this->emitLabel(LabelEnd);
} else {
LabelTy LabelEnd = this->getLabel();
if (!this->jumpFalse(LabelEnd))
return false;
if (!visitStmt(IS->getThen()))
return false;
{
LocalScope<Emitter> ThenScope(this);
if (!visitStmt(IS->getThen()))
return false;
if (!ThenScope.destroyLocals())
return false;
}
this->emitLabel(LabelEnd);
}

Expand Down
27 changes: 27 additions & 0 deletions clang/test/AST/ByteCode/if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,30 @@ namespace IfScope {
}
static_assert(foo() == 13, "");
}

namespace IfScope2 {
struct __bit_iterator {
unsigned __ctz_;
};
constexpr void __fill_n_bool(__bit_iterator) {}

constexpr void fill_n(__bit_iterator __first) {
if (false)
__fill_n_bool(__first);
else
__fill_n_bool(__first);
}

struct bitset{
constexpr void reset() {
auto m = __bit_iterator(8);
fill_n(m);
}
};
consteval bool foo() {
bitset v;
v.reset();
return true;
}
static_assert(foo());
}
Loading