Skip to content

Commit

Permalink
cg: Add visitor for gnu BuiltinTypesCompatibleP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezurko authored and xlauko committed Sep 6, 2024
1 parent 11333eb commit e71f377
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/vast/CodeGen/DefaultStmtVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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 >()
Expand Down
10 changes: 10 additions & 0 deletions lib/vast/CodeGen/DefaultStmtVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit e71f377

Please sign in to comment.