Skip to content

Commit

Permalink
[clang][Interp] Actually consider ConstantExpr result
Browse files Browse the repository at this point in the history
Since we have visitAPValue now, we might as well use it here.

Differential Revision: https://reviews.llvm.org/D158502
  • Loading branch information
tbaederr authored and ZijunZhaoCCK committed Sep 19, 2023
1 parent 48c815e commit 3c6cd24
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,14 @@ bool ByteCodeExprGen<Emitter>::VisitSubstNonTypeTemplateParmExpr(

template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitConstantExpr(const ConstantExpr *E) {
// TODO: Check if the ConstantExpr already has a value set and if so,
// use that instead of evaluating it again.
// Try to emit the APValue directly, without visiting the subexpr.
// This will only fail if we can't emit the APValue, so won't emit any
// diagnostics or any double values.
std::optional<PrimType> T = classify(E->getType());
if (T && E->hasAPValueResult() &&
this->visitAPValue(E->getAPValueResult(), *T, E))
return true;

return this->delegate(E->getSubExpr());
}

Expand Down

0 comments on commit 3c6cd24

Please sign in to comment.