summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-09-09 22:26:04 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-09-09 22:26:04 +0000
commit2ca7370183a104b7769202032e9d5a41c04ed070 (patch)
treedb09cbf5dc84be784adf48430a39af00ae10317a
parentf0e2755b45a42a3c3284c7a3cec82147065c36a2 (diff)
downloadbcm5719-llvm-2ca7370183a104b7769202032e9d5a41c04ed070.tar.gz
bcm5719-llvm-2ca7370183a104b7769202032e9d5a41c04ed070.zip
Simplify demangler rule for lambda-expressions to match discussion on
cxx-abi list. llvm-svn: 371462
-rw-r--r--libcxxabi/src/demangle/ItaniumDemangle.h60
-rw-r--r--libcxxabi/test/test_demangle.pass.cpp4
-rw-r--r--llvm/include/llvm/Demangle/ItaniumDemangle.h60
3 files changed, 35 insertions, 89 deletions
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index c1efd7ef4e3..edba17d396b 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -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, Alloc>::parseExprPrimary() {
// 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/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index 9f7f1671a5a..c84447fdef9 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -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]);
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index c1efd7ef4e3..edba17d396b 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -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, Alloc>::parseExprPrimary() {
// 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);
}
}
}
OpenPOWER on IntegriCloud