Page MenuHomePhabricator

PR19091, libcxxabi fix of wrong demangling of "operator>(int)"
AbandonedPublic

Authored by rsmith on May 7 2014, 6:41 AM.

Details

Summary

Problem is in cxa_demangle.cpp, "parse_encoding" method.

Method checks previously demangled characters to detect whether template arguments were parsed, and whether it can proceed to type parsing.
So, method misrecognises ">" as template closing tag. It wouldn't be good if we check that closing tag is not a tail of "operator>", since it won't solve whole problem. It still will conflict with constructions like "<despicable_operator>".
Current patch fixes this problem by adding extra space into demangling sequence for GT operator: "operator> ".
Though generally, it would be good if we will keep parsing stack information somewhere.

Diff Detail

Event Timeline

dyatkovskiy updated this revision to Diff 9163.May 7 2014, 6:41 AM
dyatkovskiy retitled this revision from to PR19091, libcxxabi fix of wrong demangling of "operator>(int)" .
dyatkovskiy updated this object.
dyatkovskiy edited the test plan for this revision. (Show Details)
dyatkovskiy added a subscriber: Unknown Object (MLST).

I'm not sure that this is a good solution; I don't think that there's any other place do we add a space in the demangled name (at least between things that the compiler would accept w/o the space)

I have the same opinion. IMHO, the best solution is to extend Db with information about what was parsed. But how we could solve it now? Is there any other ways to distinguish operator> from tail of "<some_operator>" ?

rsmith edited subscribers, added: Unknown Object (MLST), rsmith; removed: Unknown Object (MLST).May 7 2014, 2:33 PM

So guys, how do you find this fix?

rsmith edited edge metadata.May 12 2014, 11:19 AM

This does not seem like a reasonable approach. The problem is that we're looking at the contents of the already-demangled buffer to determine how to demangle and then making incorrect assumptions about it. We should stop making those assumptions.

It doesn't seem difficult for parse_name to track whether the last component in the <name> within an <encoding> had template arguments, and that's what we need to know to determine how to demangle a function or function template specialization.

rsmith commandeered this revision.May 12 2014, 11:52 AM
rsmith edited reviewers, added: dyatkovskiy; removed: rsmith.

Fixed in r208611.

rsmith abandoned this revision.May 12 2014, 11:52 AM