Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix demangling of namespaced type arguments #220

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 11 additions & 27 deletions llvm/include/llvm/Cheerp/Demangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,14 @@ class Demangler

for (uint32_t i=(doCleanup && isNamespaceClient())?1:0; i<scopes.size(); i++)
{
if (doCleanup)
res += cleanupTemplates(scopes[i]);
else
res += scopes[i];
res += scopes[i];
res += '.';
}

//remove last dot
res.pop_back();

return res;
return doCleanup ? cleanupTemplates(res) : res;
}
bool isNamespaceClient() const
{
Expand Down Expand Up @@ -149,33 +146,20 @@ class Demangler
private:
std::string cleanupTemplates(const std::string& name) const
{
const char close = '>';
const char open = '<';

std::string res;
int balance = 0;
uint32_t lastBalanced = name.size();

for (int i=name.size()-1; i>=0; i--)
for (char c : name)
{
bool isSpecial = false;
if (name[i] == close)
{
balance++;
isSpecial = true;
}
else if (name[i] == open)
{
balance--;
isSpecial = true;
}

if (isSpecial && balance == 0)
{
lastBalanced = i;
}
if (c == '<')
balance += 1;
if (balance == 0)
res += c;
if (c == '>')
balance -= 1;
}

return std::string(name, 0, lastBalanced);
return res;
}
std::vector<std::string> scopes;
std::string functionName{""};
Expand Down
Loading