[PATCH] D122474: demangler] Parenthesize >> inside template args

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 25 04:40:57 PDT 2022


urnathan created this revision.
urnathan added reviewers: rjmccall, bruno, dblaikie.
Herald added a project: All.
urnathan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Both > and >> expressions need to be parenthesized inside template argument lists.

(as noted in D120905 <https://reviews.llvm.org/D120905>)


https://reviews.llvm.org/D122474

Files:
  libcxxabi/src/demangle/ItaniumDemangle.h
  libcxxabi/test/test_demangle.pass.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h


Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===================================================================
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -1785,7 +1785,8 @@
   template<typename Fn> void match(Fn F) const { F(LHS, InfixOperator, RHS); }
 
   void printLeft(OutputBuffer &OB) const override {
-    bool ParenAll = OB.isGtInsideTemplateArgs() && InfixOperator == ">";
+    bool ParenAll = OB.isGtInsideTemplateArgs() &&
+                    (InfixOperator == ">" || InfixOperator == ">>");
     if (ParenAll)
       OB.printOpen();
     // Assignment is right associative, with special LHS precedence.
Index: libcxxabi/test/test_demangle.pass.cpp
===================================================================
--- libcxxabi/test/test_demangle.pass.cpp
+++ libcxxabi/test/test_demangle.pass.cpp
@@ -29629,7 +29629,7 @@
     {"_ZN5Casts8implicitILj4EEEvPN9enable_ifIXrMT_Li4EEvE4typeE",
      "void Casts::implicit<4u>(enable_if<4u %= 4, void>::type*)"},
     {"_ZN5Casts8implicitILj4EEEvPN9enable_ifIXrsT_Li4EEvE4typeE",
-     "void Casts::implicit<4u>(enable_if<4u >> 4, void>::type*)"},
+     "void Casts::implicit<4u>(enable_if<(4u >> 4), void>::type*)"},
     {"_ZN5Casts8implicitILj4EEEvPN9enable_ifIXrST_Li4EEvE4typeE",
      "void Casts::implicit<4u>(enable_if<4u >>= 4, void>::type*)"},
     {"_Z1fPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP1XS13_S12_S11_S10_SZ_SY_SX_SW_SV_SU_ST_SS_SR_SQ_SP_SO_SN_SM_SL_SK_SJ_"
Index: libcxxabi/src/demangle/ItaniumDemangle.h
===================================================================
--- libcxxabi/src/demangle/ItaniumDemangle.h
+++ libcxxabi/src/demangle/ItaniumDemangle.h
@@ -1785,7 +1785,8 @@
   template<typename Fn> void match(Fn F) const { F(LHS, InfixOperator, RHS); }
 
   void printLeft(OutputBuffer &OB) const override {
-    bool ParenAll = OB.isGtInsideTemplateArgs() && InfixOperator == ">";
+    bool ParenAll = OB.isGtInsideTemplateArgs() &&
+                    (InfixOperator == ">" || InfixOperator == ">>");
     if (ParenAll)
       OB.printOpen();
     // Assignment is right associative, with special LHS precedence.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122474.418186.patch
Type: text/x-patch
Size: 2173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220325/42e85973/attachment.bin>


More information about the llvm-commits mailing list