diff options
author | Nathan Sidwell <nathan@acm.org> | 2022-02-04 11:45:23 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2022-03-28 06:17:57 -0700 |
commit | b3b4113a23756eb5f519ff473295483874d8e164 (patch) | |
tree | 60fb39cf5d20f2e0cc3674cbe9e437aadac8196c /llvm/lib/IR/Module.cpp | |
parent | ec6d6210500682e1f5cbf1863b3286304bb5f5bd (diff) | |
download | llvm-b3b4113a23756eb5f519ff473295483874d8e164.zip llvm-b3b4113a23756eb5f519ff473295483874d8e164.tar.gz llvm-b3b4113a23756eb5f519ff473295483874d8e164.tar.bz2 |
[demangler] Add operator precedence
The demangler had no concept of operator precendence, and would
parenthesize many more subexpressions than necessary. In particular
it would parenthesize primary-expressions, such as '4', which just
looks strange. It would also parenthesize '>' expressions, just in
case they were inside a template parameter list.
This patch fixes both issues.
* Add operator precedence to the OpInfo structure, and add a
subexpression helper that will parenthesize a lower precedence
subexpression.
* Add a 'greater-than is greater-than' indicator to the output buffer,
so the expression printer knows whether it is immediately inside a
template parameter list (and must therefore parenthesize 'expr >
expr'). This is a counter, so that ...
* Add open and close printers to the output buffer, that increment and
decrement the gt-is-gt indicator.
* Parenthesize comma operators inside comma-separated lists. (probably
a rare case, but still).
This dramatically reduces the extraneous parentheses being printed.
Reviewed By: dblaikie, bruno
Differential Revision: https://reviews.llvm.org/D120905
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
0 files changed, 0 insertions, 0 deletions