[clang] 9e73656 - [clang][Interp] Support ExpressionTraitExprs
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 9 01:42:10 PST 2024
Author: Timm Bäder
Date: 2024-02-09T10:23:54+01:00
New Revision: 9e73656af524a2c592978aec91de67316c5ce69f
URL: https://github.com/llvm/llvm-project/commit/9e73656af524a2c592978aec91de67316c5ce69f
DIFF: https://github.com/llvm/llvm-project/commit/9e73656af524a2c592978aec91de67316c5ce69f.diff
LOG: [clang][Interp] Support ExpressionTraitExprs
Just push a constant bool value.
Added:
Modified:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/test/SemaCXX/expression-traits.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index bf456155b241b..2539e756226a1 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -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;
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h
index c908a9bf1ef83..ae216f5671395 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -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;
diff --git a/clang/test/SemaCXX/expression-traits.cpp b/clang/test/SemaCXX/expression-traits.cpp
index a76f0c4a6175f..64ddca091e948 100644
--- a/clang/test/SemaCXX/expression-traits.cpp
+++ b/clang/test/SemaCXX/expression-traits.cpp
@@ -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.
More information about the cfe-commits
mailing list