The demangler treats ->* as a BinaryExpr, but .* as a MemberExpr. That's inconsistent. This makes the former a MemberExpr too. However, in order to not regress the paren output, MemberExpr::print is modified to parenthesize the MemberExpr if the operator ends with '*'. Printing is affected thusly:
Before:
obj.member obj->member obj.*member (obj) ->* (member)
After:
obj.member # Unchanged obj->member # Unchanged obj.*(member) # Added paren member operand obj->*(member) # Removed paren on object operand, less whitespace
The right solution to the paren problem is to add some notion of precedence (and associativity) to Nodes, but that's a larger change that would become simpler once the refactoring I'm doing is completed.
FWIW, binutils' demangler's paren algorithm has a small idea of precedence, and will generally not emit parens when the operand is unary.
Should we add a comment here? It is confusing for reader who don't have a background.