[libcxx-commits] [libcxxabi] r371462 - Simplify demangler rule for lambda-expressions to match discussion on

Richard Smith via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 9 15:26:04 PDT 2019


Author: rsmith
Date: Mon Sep  9 15:26:04 2019
New Revision: 371462

URL: http://llvm.org/viewvc/llvm-project?rev=371462&view=rev
Log:
Simplify demangler rule for lambda-expressions to match discussion on
cxx-abi list.

Modified:
    libcxxabi/trunk/src/demangle/ItaniumDemangle.h
    libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/demangle/ItaniumDemangle.h
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/demangle/ItaniumDemangle.h?rev=371462&r1=371461&r2=371462&view=diff
==============================================================================
--- libcxxabi/trunk/src/demangle/ItaniumDemangle.h (original)
+++ libcxxabi/trunk/src/demangle/ItaniumDemangle.h Mon Sep  9 15:26:04 2019
@@ -2063,8 +2063,6 @@ public:
 class LambdaExpr : public Node {
   const Node *Type;
 
-  void printLambdaDeclarator(OutputStream &S) const;
-
 public:
   LambdaExpr(const Node *Type_) : Node(KLambdaExpr), Type(Type_) {}
 
@@ -2072,7 +2070,8 @@ public:
 
   void printLeft(OutputStream &S) const override {
     S += "[]";
-    printLambdaDeclarator(S);
+    if (Type->getKind() == KClosureTypeName)
+      static_cast<const ClosureTypeName *>(Type)->printDeclarator(S);
     S += "{...}";
   }
 };
@@ -2209,39 +2208,6 @@ FOR_EACH_NODE_KIND(SPECIALIZATION)
 
 #undef FOR_EACH_NODE_KIND
 
-inline void LambdaExpr::printLambdaDeclarator(OutputStream &S) const {
-  struct LambdaDeclaratorPrinter {
-    OutputStream &S;
-    void operator()(const ClosureTypeName *LambdaType) {
-      LambdaType->printDeclarator(S);
-    }
-
-    // Walk through any qualifiers to find the lambda-expression.
-    void operator()(const SpecialName *Name) {
-      Name->match([&](StringView, const Node *Name) { Name->visit(*this); });
-    }
-    void operator()(const NestedName *Name) {
-      Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
-    }
-    void operator()(const LocalName *Name) {
-      Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
-    }
-    void operator()(const QualifiedName *Name) {
-      Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
-    }
-    void operator()(const GlobalQualifiedName *Name) {
-      Name->match([&](const Node *Child) { Child->visit(*this); });
-    }
-    void operator()(const StdQualifiedName *Name) {
-      Name->match([&](const Node *Child) { Child->visit(*this); });
-    }
-    void operator()(const Node *) {
-      // If we can't find the lambda type, just print '[]{...}'.
-    }
-  };
-  return Type->visit(LambdaDeclaratorPrinter{S});
-}
-
 template <class T, size_t N>
 class PODSmallVector {
   static_assert(std::is_pod<T>::value,
@@ -4324,20 +4290,26 @@ Node *AbstractManglingParser<Derived, Al
     // Invalid mangled name per
     //   http://sourcerytools.com/pipermail/cxx-abi-dev/2011-August/002422.html
     return nullptr;
+  case 'U': {
+    // FIXME: Should we support LUb... for block literals?
+    if (look(1) != 'l')
+      return nullptr;
+    Node *T = parseUnnamedTypeName(nullptr);
+    if (!T || !consumeIf('E'))
+      return nullptr;
+    return make<LambdaExpr>(T);
+  }
   default: {
     // might be named type
     Node *T = getDerived().parseType();
     if (T == nullptr)
       return nullptr;
     StringView N = parseNumber();
-    if (!N.empty()) {
-      if (!consumeIf('E'))
-        return nullptr;
-      return make<IntegerCastExpr>(T, N);
-    }
-    if (consumeIf('E'))
-      return make<LambdaExpr>(T);
-    return nullptr;
+    if (N.empty())
+      return nullptr;
+    if (!consumeIf('E'))
+      return nullptr;
+    return make<IntegerCastExpr>(T, N);
   }
   }
 }

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=371462&r1=371461&r2=371462&view=diff
==============================================================================
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Mon Sep  9 15:26:04 2019
@@ -29784,7 +29784,9 @@ const char* cases[][2] =
     {"_ZNK1xMUlTyT_E_clIiEEDaS_", "auto x::'lambda'<typename $T>($T)::operator()<int>(x) const"},
     {"_ZNK1xMUlTnPA3_ivE_clILS0_0EEEDav", "auto x::'lambda'<int (*$N) [3]>()::operator()<(int [3])0>() const"},
     {"_ZNK1xMUlTyTtTyTnT_TpTnPA3_TL0__ETpTyvE_clIi1XJfEEEDav", "auto x::'lambda'<typename $T, template<typename $T0, $T $N, $T0 (*...$N0) [3]> typename $TT, typename ...$T1>()::operator()<int, X, float>() const"},
-    {"_ZN1AIiE1fIfEEvDTLZ1AIiEEUlTyTtTyTnTL1__ETL0_1_T_TL0__E_EE", "void A<int>::f<float>(decltype([]<typename $T, template<typename $T0, $T0 $N> typename $TT>($TT, int, $T){...}))"},
+    {"_ZN1AIiE1fIfEEvDTLUlTyTtTyTnTL1__ETL0_1_T_TL0__E_EE", "void A<int>::f<float>(decltype([]<typename $T, template<typename $T0, $T0 $N> typename $TT>($TT, float, $T){...}))"},
+    {"_ZN1S1fILb1EEEv1XILUlvE_EE", "void S::f<true>(X<[](){...}>)"},
+    {"_ZN1S1fILb1EEEv1XILUlvE0_EE", "void S::f<true>(X<[](){...}>)"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);




More information about the libcxx-commits mailing list