Skip to content

Commit

Permalink
chore: move TagTypeKind conversion to ASTVisitorHelpers
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkrystian committed Jun 19, 2023
1 parent c2abb69 commit 7246747
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
16 changes: 1 addition & 15 deletions source/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FinalAttr>();
Expand Down
17 changes: 17 additions & 0 deletions source/AST/ASTVisitorHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T, typename... Args>
void insertChild(NamespaceInfo& I, Args&&... args)
{
Expand Down

0 comments on commit 7246747

Please sign in to comment.