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 @@ -735,6 +735,17 @@ std::string ToString(clang::QualType qual_type) {
735735 return normalizeTranslationRule (type);
736736}
737737
738+ static std::string synthesizeAnonRecordName (const clang::RecordDecl *record) {
739+ std::string parent_name;
740+ if (auto *parent =
741+ clang::dyn_cast<clang::RecordDecl>(record->getDeclContext ())) {
742+ parent_name =
743+ parent->getIdentifier () ? parent->getIdentifier ()->getName ().str ();
744+ : synthesizeAnonRecordName (parent);
745+ }
746+ return std::format (" {}_anon_{}" , parent_name, GetAnonIndex (record));
747+ }
748+
738749std::string ToString (const clang::NamedDecl *decl) {
739750 if (auto *record = clang::dyn_cast<clang::RecordDecl>(decl);
740751 record && !record->getIdentifier ()) {
You can’t perform that action at this time.
0 commit comments