From 72467470fe6d4ba9b93586cc787702821fa441ee Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Mon, 19 Jun 2023 10:53:46 -0400 Subject: [PATCH] chore: move TagTypeKind conversion to ASTVisitorHelpers --- source/AST/ASTVisitor.cpp | 16 +--------------- source/AST/ASTVisitorHelpers.hpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/source/AST/ASTVisitor.cpp b/source/AST/ASTVisitor.cpp index 868ce0786..de0238b13 100644 --- a/source/AST/ASTVisitor.cpp +++ b/source/AST/ASTVisitor.cpp @@ -788,21 +788,7 @@ buildRecord( else I.Loc.emplace_back(line, File_.str(), IsFileInRootDir_); - switch(D->getTagKind()) - { - case TagTypeKind::TTK_Struct: - I.KeyKind = RecordKeyKind::Struct; - break; - case TagTypeKind::TTK_Class: - I.KeyKind = RecordKeyKind::Class; - break; - case TagTypeKind::TTK_Union: - I.KeyKind = RecordKeyKind::Union; - break; - default: - // unsupported TagTypeKind - MRDOX_UNREACHABLE(); - } + I.KeyKind = convertToRecordKeyKind(D->getTagKind()); // These are from CXXRecordDecl::isEffectivelyFinal() I.specs.isFinal = D->template hasAttr(); diff --git a/source/AST/ASTVisitorHelpers.hpp b/source/AST/ASTVisitorHelpers.hpp index 172e55fc5..906037770 100644 --- a/source/AST/ASTVisitorHelpers.hpp +++ b/source/AST/ASTVisitorHelpers.hpp @@ -202,6 +202,23 @@ convertToReferenceKind( } } +RecordKeyKind +convertToRecordKeyKind( + TagTypeKind kind) +{ + using OldKind = TagTypeKind; + using NewKind = RecordKeyKind; + switch(kind) + { + case OldKind::TTK_Struct: return NewKind::Struct; + case OldKind::TTK_Class: return NewKind::Class; + case OldKind::TTK_Union: return NewKind::Union; + default: + // unsupported TagTypeKind + MRDOX_UNREACHABLE(); + } +} + template void insertChild(NamespaceInfo& I, Args&&... args) {