File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2837,10 +2837,6 @@ std::string Converter::GetRecordName(const clang::NamedDecl *decl) const {
28372837 if (auto it = inner_structs_.find (ID); it != inner_structs_.end ()) {
28382838 return it->second ;
28392839 }
2840- if (auto *record = clang::dyn_cast<clang::RecordDecl>(decl);
2841- record && !record->getIdentifier ()) {
2842- return ID;
2843- }
28442840 return std::regex_replace (Mapper::ToString (decl), std::regex (" ::" ), " _" );
28452841}
28462842
Original file line number Diff line number Diff line change @@ -734,6 +734,17 @@ std::string ToString(clang::QualType qual_type) {
734734 return normalizeTranslationRule (type);
735735}
736736
737+ static std::string synthesizeAnonRecordName (const clang::RecordDecl *record) {
738+ std::string parent_name;
739+ if (auto *parent =
740+ clang::dyn_cast<clang::RecordDecl>(record->getDeclContext ())) {
741+ parent_name =
742+ parent->getIdentifier () ? parent->getIdentifier ()->getName ().str ();
743+ : synthesizeAnonRecordName (parent);
744+ }
745+ return std::format (" {}_anon_{}" , parent_name, GetAnonIndex (record));
746+ }
747+
737748std::string ToString (const clang::NamedDecl *decl) {
738749 if (auto *record = clang::dyn_cast<clang::RecordDecl>(decl);
739750 record && !record->getIdentifier ()) {
You can’t perform that action at this time.
0 commit comments