Simplify demangler rule for lambda-expressions to match discussion on
cxx-abi list.

git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@371462 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/demangle/ItaniumDemangle.h b/src/demangle/ItaniumDemangle.h
index c1efd7e..edba17d 100644
--- a/src/demangle/ItaniumDemangle.h
+++ b/src/demangle/ItaniumDemangle.h
@@ -2063,8 +2063,6 @@
 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 @@
 
   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 @@
 
 #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 @@
     // 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);
   }
   }
 }
diff --git a/test/test_demangle.pass.cpp b/test/test_demangle.pass.cpp
index 9f7f167..c84447f 100644
--- a/test/test_demangle.pass.cpp
+++ b/test/test_demangle.pass.cpp
@@ -29784,7 +29784,9 @@
     {"_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]);