From 472a7366ee14ee6366d9b04f287127b98f8f20fb Mon Sep 17 00:00:00 2001 From: Jon Haslam Date: Tue, 16 Apr 2024 12:53:36 +0100 Subject: [PATCH] ClangTypeParser: handle clang::MemberPointer (#493) --- oi/type_graph/ClangTypeParser.cpp | 9 +++++++++ oi/type_graph/ClangTypeParser.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/oi/type_graph/ClangTypeParser.cpp b/oi/type_graph/ClangTypeParser.cpp index 6510bb7..222c9e7 100644 --- a/oi/type_graph/ClangTypeParser.cpp +++ b/oi/type_graph/ClangTypeParser.cpp @@ -109,6 +109,9 @@ Type& ClangTypeParser::enumerateType(const clang::Type& ty) { return enumerateArray(llvm::cast(ty)); case clang::Type::Enum: return enumerateEnum(llvm::cast(ty)); + case clang::Type::MemberPointer: + return enumerateMemberPointer( + llvm::cast(ty)); default: throw std::logic_error(std::string("unsupported TypeClass `") + @@ -385,6 +388,12 @@ Type& ClangTypeParser::enumeratePointer(const clang::PointerType& ty) { return makeType(ty, t); } +Type& ClangTypeParser::enumerateMemberPointer( + const clang::MemberPointerType& ty) { + // TODO: chase anything not a function pointer (same as regular pointers). + return makeType(ty, Primitive::Kind::StubbedPointer); +} + Type& ClangTypeParser::enumerateSubstTemplateTypeParm( const clang::SubstTemplateTypeParmType& ty) { // Clang wraps any type that was substituted from e.g. `T` in this type. It diff --git a/oi/type_graph/ClangTypeParser.h b/oi/type_graph/ClangTypeParser.h index e7daaa1..39301e7 100644 --- a/oi/type_graph/ClangTypeParser.h +++ b/oi/type_graph/ClangTypeParser.h @@ -29,6 +29,7 @@ class DecltypeType; class ElaboratedType; class EnumType; class LValueReferenceType; +class MemberPointerType; class PointerType; class RecordType; class Sema; @@ -97,6 +98,7 @@ class ClangTypeParser { Type& enumerateClass(const clang::RecordType&); Type& enumerateReference(const clang::LValueReferenceType&); Type& enumeratePointer(const clang::PointerType&); + Type& enumerateMemberPointer(const clang::MemberPointerType&); Type& enumerateSubstTemplateTypeParm(const clang::SubstTemplateTypeParmType&); Primitive& enumeratePrimitive(const clang::BuiltinType&); Type& enumerateElaboratedType(const clang::ElaboratedType&);