Skip to content

Commit

Permalink
[clang][Interp] Support ChooseExprs
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Feb 2, 2024
1 parent 2147a2a commit 58ceefe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,11 @@ bool ByteCodeExprGen<Emitter>::VisitGenericSelectionExpr(
return this->delegate(E->getResultExpr());
}

template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitChooseExpr(const ChooseExpr *E) {
return this->delegate(E->getChosenSubExpr());
}

template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
if (E->containsErrors())
return false;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/Interp/ByteCodeExprGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E);
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
bool VisitGenericSelectionExpr(const GenericSelectionExpr *E);
bool VisitChooseExpr(const ChooseExpr *E);

protected:
bool visitExpr(const Expr *E) override;
Expand Down
3 changes: 3 additions & 0 deletions clang/test/AST/Interp/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ void f (int z) {
// pedantic-ref-error {{'default' statement not in switch}}
}
}

int expr;
int chooseexpr[__builtin_choose_expr(1, 1, expr)];

0 comments on commit 58ceefe

Please sign in to comment.