Skip to content

Commit 7246747

Browse files
committed
chore: move TagTypeKind conversion to ASTVisitorHelpers
1 parent c2abb69 commit 7246747

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

source/AST/ASTVisitor.cpp

+1-15
Original file line numberDiff line numberDiff line change
@@ -788,21 +788,7 @@ buildRecord(
788788
else
789789
I.Loc.emplace_back(line, File_.str(), IsFileInRootDir_);
790790

791-
switch(D->getTagKind())
792-
{
793-
case TagTypeKind::TTK_Struct:
794-
I.KeyKind = RecordKeyKind::Struct;
795-
break;
796-
case TagTypeKind::TTK_Class:
797-
I.KeyKind = RecordKeyKind::Class;
798-
break;
799-
case TagTypeKind::TTK_Union:
800-
I.KeyKind = RecordKeyKind::Union;
801-
break;
802-
default:
803-
// unsupported TagTypeKind
804-
MRDOX_UNREACHABLE();
805-
}
791+
I.KeyKind = convertToRecordKeyKind(D->getTagKind());
806792

807793
// These are from CXXRecordDecl::isEffectivelyFinal()
808794
I.specs.isFinal = D->template hasAttr<FinalAttr>();

source/AST/ASTVisitorHelpers.hpp

+17
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,23 @@ convertToReferenceKind(
202202
}
203203
}
204204

205+
RecordKeyKind
206+
convertToRecordKeyKind(
207+
TagTypeKind kind)
208+
{
209+
using OldKind = TagTypeKind;
210+
using NewKind = RecordKeyKind;
211+
switch(kind)
212+
{
213+
case OldKind::TTK_Struct: return NewKind::Struct;
214+
case OldKind::TTK_Class: return NewKind::Class;
215+
case OldKind::TTK_Union: return NewKind::Union;
216+
default:
217+
// unsupported TagTypeKind
218+
MRDOX_UNREACHABLE();
219+
}
220+
}
221+
205222
template<typename T, typename... Args>
206223
void insertChild(NamespaceInfo& I, Args&&... args)
207224
{

0 commit comments

Comments
 (0)