Skip to content

Commit f91fdd3

Browse files
committed
Fix translation of type of anon enum
1 parent 008e94f commit f91fdd3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

cpp2rust/converter/mapper.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,11 @@ std::string ToString(clang::QualType qual_type) {
724724
}
725725
}
726726

727+
if (auto *tag = qual_type->getAsTagDecl();
728+
tag && !tag->getIdentifier() && !tag->getTypedefNameForAnonDecl()) {
729+
return ToString(clang::cast<clang::NamedDecl>(tag));
730+
}
731+
727732
std::string type;
728733
llvm::raw_string_ostream os(type);
729734
normalizeQualType(qual_type).print(os, getPrintPolicy());
@@ -738,7 +743,7 @@ std::string ToString(const clang::NamedDecl *decl) {
738743

739744
if (auto *enum_decl = clang::dyn_cast<clang::EnumDecl>(decl);
740745
enum_decl && !enum_decl->getIdentifier() &&
741-
enum_decl->getTypedefNameForAnonDecl() == nullptr) {
746+
!enum_decl->getTypedefNameForAnonDecl()) {
742747
return std::format("anon_enum_{}", GetLineNumber(enum_decl));
743748
}
744749

0 commit comments

Comments
 (0)