Skip to content

Commit

Permalink
Fix autogenerated RTTI names
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Sep 9, 2023
1 parent 8428a3a commit 6e29b0d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/ReGenny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,28 @@ void ReGenny::rtti_ui() {
continue;
}

const auto demangled = tname->substr(4, tname->find_first_of("@@") - 4);
std::vector<uint8_t> bad_chars{
'<', '>', ':', '"', '/', '\\', '|', '?', '*', '\0', '\a', '\b', '\f', '\n', '\r', '\t',
' ', ',', ';', '=', '(', ')', '[', ']', '{', '}'
};

std::string demangled{};
demangled.reserve(tname->length());

// replace bad characters with underscores
for (auto&& c : *tname) {
if (std::find(bad_chars.begin(), bad_chars.end(), c) != bad_chars.end()) {
demangled += '_';
} else {
demangled += c;
}
}

if (demangled.starts_with("class")) {
demangled = demangled.substr(5);
} else if (demangled.starts_with("struct")) {
demangled = demangled.substr(6);
}

counts[demangled] += 1;
const auto count = counts[demangled];
Expand Down

0 comments on commit 6e29b0d

Please sign in to comment.