[clang][Interp] Handle SubstNonTypeTemplateParmExprs

Differential Revision: https://reviews.llvm.org/D132831
This commit is contained in:
Timm Bäder 2022-08-27 17:37:26 +02:00
parent 4d700ffe67
commit 5c4dbff0b6
3 changed files with 15 additions and 0 deletions

View File

@ -231,6 +231,12 @@ bool ByteCodeExprGen<Emitter>::VisitImplicitValueInitExpr(const ImplicitValueIni
return false;
}
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitSubstNonTypeTemplateParmExpr(
const SubstNonTypeTemplateParmExpr *E) {
return this->visit(E->getReplacement());
}
template <class Emitter>
bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/true);

View File

@ -76,6 +76,7 @@ public:
bool VisitUnaryOperator(const UnaryOperator *E);
bool VisitDeclRefExpr(const DeclRefExpr *E);
bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E);
bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E);
protected:
bool visitExpr(const Expr *E) override;

View File

@ -65,3 +65,11 @@ constexpr int recursion(int i) {
return recursion(i);
}
static_assert(recursion(10) == 0, "");
template<int N = 5>
constexpr decltype(N) getNum() {
return N;
}
static_assert(getNum<-2>() == -2, "");
static_assert(getNum<10>() == 10, "");
static_assert(getNum() == 5, "");