From 376e08a01a6cc4de5106cc2746baf602d6d33798 Mon Sep 17 00:00:00 2001 From: Robert Konicar Date: Fri, 18 Oct 2024 19:30:45 +0200 Subject: [PATCH] cg: Add visitors for new types from clang 19. --- include/vast/CodeGen/DefaultTypeVisitor.hpp | 6 ++++ lib/vast/CodeGen/DefaultTypeVisitor.cpp | 36 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/vast/CodeGen/DefaultTypeVisitor.hpp b/include/vast/CodeGen/DefaultTypeVisitor.hpp index 135fe1b01a..44adea3dfb 100644 --- a/include/vast/CodeGen/DefaultTypeVisitor.hpp +++ b/include/vast/CodeGen/DefaultTypeVisitor.hpp @@ -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); diff --git a/lib/vast/CodeGen/DefaultTypeVisitor.cpp b/lib/vast/CodeGen/DefaultTypeVisitor.cpp index b784b30c42..3a75fe1b95 100644 --- a/lib/vast/CodeGen/DefaultTypeVisitor.cpp +++ b/lib/vast/CodeGen/DefaultTypeVisitor.cpp @@ -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); } @@ -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 */); }