Skip to content

Commit

Permalink
[clang][Interp] Support ExpressionTraitExprs
Browse files Browse the repository at this point in the history
Just push a constant bool value.
  • Loading branch information
tbaederr committed Feb 9, 2024
1 parent 79e43eb commit 9e73656
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,13 @@ bool ByteCodeExprGen<Emitter>::VisitCXXInheritedCtorInitExpr(
return this->emitCall(F, E);
}

template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitExpressionTraitExpr(
const ExpressionTraitExpr *E) {
assert(Ctx.getLangOpts().CPlusPlus);
return this->emitConstBool(E->getValue(), E);
}

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 @@ -112,6 +112,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
bool VisitChooseExpr(const ChooseExpr *E);
bool VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E);
bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
bool VisitExpressionTraitExpr(const ExpressionTraitExpr *E);

protected:
bool visitExpr(const Expr *E) override;
Expand Down
1 change: 1 addition & 0 deletions clang/test/SemaCXX/expression-traits.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -fcxx-exceptions %s
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -fcxx-exceptions %s -fexperimental-new-constant-interpreter

//
// Tests for "expression traits" intrinsics such as __is_lvalue_expr.
Expand Down

0 comments on commit 9e73656

Please sign in to comment.