[PATCH] D120905: [demangler] Add operator precedence
Nathan Sidwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 25 04:22:53 PDT 2022
urnathan added inline comments.
================
Comment at: libcxxabi/src/demangle/ItaniumDemangle.h:1788
void printLeft(OutputBuffer &OB) const override {
- // might be a template argument expression, then we need to disambiguate
- // with parens.
- if (InfixOperator == ">")
- OB += "(";
-
- OB += "(";
- LHS->print(OB);
- OB += ") ";
+ bool ParenAll = OB.isGtInsideTemplateArgs() && InfixOperator == ">";
+ if (ParenAll)
----------------
rjmccall wrote:
> Does this not need to apply to `>>` for some reason, or does demangling just have a longstanding bug?
you remind me that I puzzled about this, it is indeed a long-standing bug that we can deal with in a followup?
pre-patch we special cased ">" in an equivalent manner to here, but not ">>":
```
// might be a template argument expression, then we need to disambiguate
// with parens.
if (InfixOperator == ">")
OB += "(";
```
I guess that predates C++'s splitting of >> in template arg parsing?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120905/new/
https://reviews.llvm.org/D120905
More information about the llvm-commits
mailing list