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
6 changes: 2 additions & 4 deletions clang/lib/AST/ByteCode/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ Context::~Context() {}

bool Context::isPotentialConstantExpr(State &Parent, const FunctionDecl *FD) {
assert(Stk.empty());
Function *Func = P->getFunction(FD);
if (!Func || !Func->hasBody())
Func = Compiler<ByteCodeEmitter>(*this, *P).compileFunc(FD);

const Function *Func = getOrCreateFunction(FD);
if (!Func)
return false;

Expand Down Expand Up @@ -271,6 +268,7 @@ Context::getOverridingFunction(const CXXRecordDecl *DynamicDecl,

const Function *Context::getOrCreateFunction(const FunctionDecl *FD) {
assert(FD);
FD = FD->getMostRecentDecl();
const Function *Func = P->getFunction(FD);
bool IsBeingCompiled = Func && Func->isDefined() && !Func->isFullyCompiled();
bool WasNotDefined = Func && !Func->isConstexpr() && !Func->isDefined();
Expand Down
9 changes: 9 additions & 0 deletions clang/test/AST/ByteCode/cxx2a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,12 @@ namespace TypeId {
}
static_assert(side_effects());
}

consteval int f(int i);
constexpr bool test(auto i) {
return f(0) == 0;
}
consteval int f(int i) {
return 2 * i;
}
static_assert(test(42));
Loading