Skip to content

Commit f03a35f

Browse files
committed
cg: Implement unsupported type visitor.
1 parent 43bc383 commit f03a35f

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

include/vast/CodeGen/UnsupportedVisitor.hpp

+21-7
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,29 @@ namespace vast::cg {
3232
};
3333

3434
template< typename Derived >
35-
struct UnsupportedTypeVisitor {
36-
mlir_type Visit(clang::QualType type) {
37-
// TODO
38-
VAST_UNREACHABLE("unsupported type: {0}", type.getAsString());
35+
struct UnsupportedTypeVisitor
36+
: clang::TypeVisitor< UnsupportedTypeVisitor< Derived >, mlir_type >
37+
, CodeGenVisitorLens< UnsupportedTypeVisitor< Derived >, Derived >
38+
, CodeGenBuilder< UnsupportedTypeVisitor< Derived >, Derived >
39+
{
40+
using LensType = CodeGenVisitorLens< UnsupportedTypeVisitor< Derived >, Derived >;
41+
42+
using LensType::mcontext;
43+
using LensType::visit;
44+
45+
auto make_unsupported_type(auto ty) {
46+
return this->template make_type< us::UnsupportedType >()
47+
.bind(&mcontext())
48+
.bind(ty->getTypeClassName())
49+
.freeze();
3950
}
4051

41-
mlir_type Visit(const clang::Type *type) {
42-
// TODO
43-
VAST_UNREACHABLE("unsupported type: {0}", type->getTypeClassName());
52+
mlir_type Visit(clang::QualType ty) {
53+
return ty.isNull() ? Type() : Visit(ty.getTypePtr());
54+
}
55+
56+
mlir_type Visit(const clang_type *ty) {
57+
return make_unsupported_type(ty);
4458
}
4559
};
4660

0 commit comments

Comments
 (0)