[libcxx-commits] [libcxxabi] ed2d4da - [demangler] Fold expressions of .* and ->*

Nathan Sidwell via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 3 06:46:12 PDT 2022


Author: Nathan Sidwell
Date: 2022-05-03T06:45:25-07:00
New Revision: ed2d4da732006d76e2f7b4315a2056b2d7b2f15c

URL: https://github.com/llvm/llvm-project/commit/ed2d4da732006d76e2f7b4315a2056b2d7b2f15c
DIFF: https://github.com/llvm/llvm-project/commit/ed2d4da732006d76e2f7b4315a2056b2d7b2f15c.diff

LOG: [demangler] Fold expressions of .* and ->*

(Exitingly) a fold expression's operators include .* and ->*, but we
failed to demangle them as we categorize those as MemberExprs, not
BinaryExprs.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D123305

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index a504b06fc7e0a..7893cb0bff0eb 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -4447,7 +4447,11 @@ Node *AbstractManglingParser<Derived, Alloc>::parseFoldExpr() {
   ++First;
 
   const auto *Op = parseOperatorEncoding();
-  if (!Op || Op->getKind() != OperatorInfo::Binary)
+  if (!Op)
+    return nullptr;
+  if (!(Op->getKind() == OperatorInfo::Binary
+        || (Op->getKind() == OperatorInfo::Member
+            && Op->getName().back() == '*')))
     return nullptr;
 
   Node *Pack = getDerived().parseExpr();

diff  --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index 172f15ff7ad0f..b0295ce0344dd 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -29963,6 +29963,8 @@ const char* cases[][2] =
      "void Partial<1, 2>::foldr<3, 4>(A<1 + (2 + ((3, 4) + ... + (1 + (2 + ((3, 4) + ...)))))>)"},
     {"_ZN7PartialIJLi1ELi2EEE5foldrIJLi3ELi4EEEEv1AIXplplLi1ELi2EfRplT_plplLi1ELi2EflplT_EE",
      "void Partial<1, 2>::foldr<3, 4>(A<1 + 2 + ((3, 4) + ... + (1 + 2 + (... + (3, 4))))>)"},
+    {"_Z1fIXfLpm1x1yEEvv", "void f<(x ->* ... ->* (y...))>()"},
+    {"_Z1fIXfLds1x1yEEvv", "void f<(x .* ... .* (y...))>()"},
 
     // reference collapsing:
     {"_Z1fIR1SEiOT_", "int f<S&>(S&)"},
@@ -30173,6 +30175,9 @@ const char* invalid_cases[] =
     "_ZN1fIiEEvNTUt_E",
     "_ZNDTUt_Ev",
 
+    "_Z1fIXfLpt1x1yEEvv",
+    "_Z1fIXfLdt1x1yEEvv",
+
     "_ZN1fIXawLi0EEEEvv",
 
     "_ZNWUt_3FOOEv",

diff  --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 53f444a868367..5e9a79ab82693 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -4447,7 +4447,11 @@ Node *AbstractManglingParser<Derived, Alloc>::parseFoldExpr() {
   ++First;
 
   const auto *Op = parseOperatorEncoding();
-  if (!Op || Op->getKind() != OperatorInfo::Binary)
+  if (!Op)
+    return nullptr;
+  if (!(Op->getKind() == OperatorInfo::Binary
+        || (Op->getKind() == OperatorInfo::Member
+            && Op->getName().back() == '*')))
     return nullptr;
 
   Node *Pack = getDerived().parseExpr();


        


More information about the libcxx-commits mailing list