Skip to content

Commit 9e73656

Browse files
committed
[clang][Interp] Support ExpressionTraitExprs
Just push a constant bool value.
1 parent 79e43eb commit 9e73656

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,13 @@ bool ByteCodeExprGen<Emitter>::VisitCXXInheritedCtorInitExpr(
20512051
return this->emitCall(F, E);
20522052
}
20532053

2054+
template <class Emitter>
2055+
bool ByteCodeExprGen<Emitter>::VisitExpressionTraitExpr(
2056+
const ExpressionTraitExpr *E) {
2057+
assert(Ctx.getLangOpts().CPlusPlus);
2058+
return this->emitConstBool(E->getValue(), E);
2059+
}
2060+
20542061
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
20552062
if (E->containsErrors())
20562063
return false;

clang/lib/AST/Interp/ByteCodeExprGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
112112
bool VisitChooseExpr(const ChooseExpr *E);
113113
bool VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E);
114114
bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
115+
bool VisitExpressionTraitExpr(const ExpressionTraitExpr *E);
115116

116117
protected:
117118
bool visitExpr(const Expr *E) override;

clang/test/SemaCXX/expression-traits.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -fcxx-exceptions %s
2+
// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -fcxx-exceptions %s -fexperimental-new-constant-interpreter
23

34
//
45
// Tests for "expression traits" intrinsics such as __is_lvalue_expr.

0 commit comments

Comments
 (0)