diff --git a/include/vast/CodeGen/DefaultStmtVisitor.hpp b/include/vast/CodeGen/DefaultStmtVisitor.hpp index 24f635d1a1..f7e66c6b34 100644 --- a/include/vast/CodeGen/DefaultStmtVisitor.hpp +++ b/include/vast/CodeGen/DefaultStmtVisitor.hpp @@ -244,6 +244,9 @@ namespace vast::cg { // operation VisitParenListExpr(const clang::ParenListExpr *expr) operation VisitStmtExpr(const clang::StmtExpr *expr); + template< typename op_t > + operation mk_type_trait_expr(const clang::TypeTraitExpr *expr); + template< typename op_t > operation mk_type_trait_expr(const clang::UnaryExprOrTypeTraitExpr *expr); @@ -254,6 +257,7 @@ namespace vast::cg { operation mk_trait_expr(const clang::UnaryExprOrTypeTraitExpr *expr); operation VisitUnaryExprOrTypeTraitExpr(const clang::UnaryExprOrTypeTraitExpr *expr); + operation VisitTypeTraitExpr(const clang::TypeTraitExpr *expr); operation VisitVAArgExpr(const clang::VAArgExpr *expr); operation VisitNullStmt(const clang::NullStmt *stmt); operation VisitCXXThisExpr(const clang::CXXThisExpr *expr); @@ -476,6 +480,20 @@ namespace vast::cg { return {}; } + template< typename op_t > + operation default_stmt_visitor::mk_type_trait_expr(const clang::TypeTraitExpr *expr) { + types_t types; + for (auto type_info : expr->getArgs()) { + types.push_back(self.visit(type_info->getType())); + } + return bld.compose< op_t >() + .bind(self.location(expr)) + .bind(self.visit(expr->getType())) + .bind(types) + .bind_always(expr->isValueDependent() ? std::nullopt : std::optional(expr->getValue())) + .freeze(); + } + template< typename op_t > operation default_stmt_visitor::mk_type_trait_expr(const clang::UnaryExprOrTypeTraitExpr *expr) { return bld.compose< op_t >() diff --git a/lib/vast/CodeGen/DefaultStmtVisitor.cpp b/lib/vast/CodeGen/DefaultStmtVisitor.cpp index 7094e531ff..46a10865e8 100644 --- a/lib/vast/CodeGen/DefaultStmtVisitor.cpp +++ b/lib/vast/CodeGen/DefaultStmtVisitor.cpp @@ -1093,6 +1093,16 @@ namespace vast::cg } } + operation default_stmt_visitor::VisitTypeTraitExpr(const clang::TypeTraitExpr *expr) { + switch (expr->getTrait()) { + case clang::BTT_TypeCompatible: + return mk_type_trait_expr< hl::BuiltinTypesCompatiblePOp >(expr); + default: + return {}; + } + return {}; + } + operation default_stmt_visitor::VisitVAArgExpr(const clang::VAArgExpr *expr) { return bld.compose< hl::VAArgExpr >() .bind(self.location(expr))