Skip to content

Commit

Permalink
cg: Add visitors for new types from clang 19.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezurko committed Nov 4, 2024
1 parent 64e902c commit 3cd8907
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/vast/CodeGen/DefaultTypeVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ namespace vast::cg {
mlir_type VisitParenType(const clang::ParenType *ty);
mlir_type VisitParenType(const clang::ParenType *ty, clang_qualifiers quals);

mlir_type VisitMacroQualifiedType(const clang::MacroQualifiedType *ty);
mlir_type VisitMacroQualifiedType(const clang::MacroQualifiedType *ty, clang_qualifiers quals);

mlir_type VisitCountAttributedType(const clang::CountAttributedType *ty);
mlir_type VisitCountAttributedType(const clang::CountAttributedType *ty, clang_qualifiers quals);

mlir_type VisitFunctionType(const clang::FunctionType *ty);

mlir_type VisitFunctionProtoType(const clang::FunctionProtoType *ty);
Expand Down
36 changes: 36 additions & 0 deletions lib/vast/CodeGen/DefaultTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ namespace vast::cg {
return VisitParenType(t, quals);
}

if (auto t = llvm::dyn_cast< clang::MacroQualifiedType >(underlying)) {
return VisitMacroQualifiedType(t, quals);
}

if (auto t = llvm::dyn_cast< clang::CountAttributedType >(underlying)) {
return VisitCountAttributedType(t, quals);
}

if (auto t = llvm::dyn_cast< clang::FunctionProtoType >(underlying)) {
return VisitFunctionProtoType(t, quals);
}
Expand Down Expand Up @@ -344,6 +352,34 @@ namespace vast::cg {
return hl::ParenType::get(&mctx, self.visit(ty->getInnerType()));
}

mlir_type default_type_visitor::VisitMacroQualifiedType(const clang::MacroQualifiedType *ty) {
return VisitMacroQualifiedType(ty, ty->desugar().getLocalQualifiers());
}

mlir_type default_type_visitor::VisitMacroQualifiedType(const clang::MacroQualifiedType *ty, clang_qualifiers quals) {
return hl::MacroQualifiedType::get(&mctx, self.visit(ty->getUnderlyingType()));
}

mlir_type default_type_visitor::VisitCountAttributedType(const clang::CountAttributedType *ty) {
return VisitCountAttributedType(ty, ty->desugar().getLocalQualifiers());
}

mlir_type default_type_visitor::VisitCountAttributedType(const clang::CountAttributedType *ty, clang_qualifiers quals) {
auto get_kind = [](auto kind) {
switch (kind) {
case clang::CountAttributedType::DynamicCountPointerKind::CountedBy:
return hl::CountType::CountedBy;
case clang::CountAttributedType::DynamicCountPointerKind::SizedBy:
return hl::CountType::SizedBy;
case clang::CountAttributedType::DynamicCountPointerKind::CountedByOrNull:
return hl::CountType::CountedByOrNull;
case clang::CountAttributedType::DynamicCountPointerKind::SizedByOrNull:
return hl::CountType::SizedByOrNull;
}
};
return hl::CountAttributedType::get(&mctx, get_kind(ty->getKind()), self.visit(ty->desugar()));
}

mlir_type default_type_visitor::VisitFunctionType(const clang::FunctionType *ty) {
return visit_function_type(self, mctx, ty, false /* variadic */);
}
Expand Down

0 comments on commit 3cd8907

Please sign in to comment.