diff --git a/include/vast/Dialect/HighLevel/HighLevelOps.hpp b/include/vast/Dialect/HighLevel/HighLevelOps.hpp index 690247176e..69940e4b1a 100644 --- a/include/vast/Dialect/HighLevel/HighLevelOps.hpp +++ b/include/vast/Dialect/HighLevel/HighLevelOps.hpp @@ -86,4 +86,10 @@ namespace vast::hl namespace vast::hl { FuncOp getCallee(CallOp call); + + using funclike_ops = util::type_list< + hl::FuncOp, + hl::MethodOp, + hl::DtorOp + >; } \ No newline at end of file diff --git a/include/vast/Translation/CodeGenContext.hpp b/include/vast/Translation/CodeGenContext.hpp index 9acbcd6dbc..cdee2825b2 100644 --- a/include/vast/Translation/CodeGenContext.hpp +++ b/include/vast/Translation/CodeGenContext.hpp @@ -205,28 +205,9 @@ namespace vast::cg return symbol(dtordecls, mangled, "undeclared destructor '" + mangled.name + "'", with_error); } - template< typename Op > - struct is_funclike { - static constexpr bool value = false; - }; - - template<> - struct is_funclike< hl::FuncOp > { - static constexpr bool value = true; - }; - - template<> - struct is_funclike< hl::MethodOp > { - static constexpr bool value = true; - }; - - template<> - struct is_funclike< hl::DtorOp > { - static constexpr bool value = true; - }; - template< typename Op > Op declare(mangled_name_ref mangled, auto vast_decl_builder) { + static_assert(hl::funclike_ops::contains< Op >, "Declaring unknown operation type"); if constexpr (std::is_same_v< Op, hl::FuncOp >) { return declare< Op >(funcdecls, mangled, vast_decl_builder, mangled.name); } else if constexpr (std::is_same_v< Op, hl::MethodOp >) { @@ -234,7 +215,6 @@ namespace vast::cg } else if constexpr (std::is_same_v< Op, hl::DtorOp >) { return declare< Op >(dtordecls, mangled, vast_decl_builder, mangled.name); } - static_assert(is_funclike< Op >::value, "Declaring unknown operation type"); } mlir_value declare(const clang::VarDecl *decl, mlir_value vast_value) {