Skip to content

Commit 2daf732

Browse files
committed
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
1 parent 950f33f commit 2daf732

File tree

2 files changed

+19
-45
lines changed

2 files changed

+19
-45
lines changed

src/demangle/ItaniumDemangle.h

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,16 +2063,15 @@ class StringLiteral : public Node {
20632063
class LambdaExpr : public Node {
20642064
const Node *Type;
20652065

2066-
void printLambdaDeclarator(OutputStream &S) const;
2067-
20682066
public:
20692067
LambdaExpr(const Node *Type_) : Node(KLambdaExpr), Type(Type_) {}
20702068

20712069
template<typename Fn> void match(Fn F) const { F(Type); }
20722070

20732071
void printLeft(OutputStream &S) const override {
20742072
S += "[]";
2075-
printLambdaDeclarator(S);
2073+
if (Type->getKind() == KClosureTypeName)
2074+
static_cast<const ClosureTypeName *>(Type)->printDeclarator(S);
20762075
S += "{...}";
20772076
}
20782077
};
@@ -2209,39 +2208,6 @@ FOR_EACH_NODE_KIND(SPECIALIZATION)
22092208

22102209
#undef FOR_EACH_NODE_KIND
22112210

2212-
inline void LambdaExpr::printLambdaDeclarator(OutputStream &S) const {
2213-
struct LambdaDeclaratorPrinter {
2214-
OutputStream &S;
2215-
void operator()(const ClosureTypeName *LambdaType) {
2216-
LambdaType->printDeclarator(S);
2217-
}
2218-
2219-
// Walk through any qualifiers to find the lambda-expression.
2220-
void operator()(const SpecialName *Name) {
2221-
Name->match([&](StringView, const Node *Name) { Name->visit(*this); });
2222-
}
2223-
void operator()(const NestedName *Name) {
2224-
Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
2225-
}
2226-
void operator()(const LocalName *Name) {
2227-
Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
2228-
}
2229-
void operator()(const QualifiedName *Name) {
2230-
Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
2231-
}
2232-
void operator()(const GlobalQualifiedName *Name) {
2233-
Name->match([&](const Node *Child) { Child->visit(*this); });
2234-
}
2235-
void operator()(const StdQualifiedName *Name) {
2236-
Name->match([&](const Node *Child) { Child->visit(*this); });
2237-
}
2238-
void operator()(const Node *) {
2239-
// If we can't find the lambda type, just print '[]{...}'.
2240-
}
2241-
};
2242-
return Type->visit(LambdaDeclaratorPrinter{S});
2243-
}
2244-
22452211
template <class T, size_t N>
22462212
class PODSmallVector {
22472213
static_assert(std::is_pod<T>::value,
@@ -4324,20 +4290,26 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExprPrimary() {
43244290
// Invalid mangled name per
43254291
// http://sourcerytools.com/pipermail/cxx-abi-dev/2011-August/002422.html
43264292
return nullptr;
4293+
case 'U': {
4294+
// FIXME: Should we support LUb... for block literals?
4295+
if (look(1) != 'l')
4296+
return nullptr;
4297+
Node *T = parseUnnamedTypeName(nullptr);
4298+
if (!T || !consumeIf('E'))
4299+
return nullptr;
4300+
return make<LambdaExpr>(T);
4301+
}
43274302
default: {
43284303
// might be named type
43294304
Node *T = getDerived().parseType();
43304305
if (T == nullptr)
43314306
return nullptr;
43324307
StringView N = parseNumber();
4333-
if (!N.empty()) {
4334-
if (!consumeIf('E'))
4335-
return nullptr;
4336-
return make<IntegerCastExpr>(T, N);
4337-
}
4338-
if (consumeIf('E'))
4339-
return make<LambdaExpr>(T);
4340-
return nullptr;
4308+
if (N.empty())
4309+
return nullptr;
4310+
if (!consumeIf('E'))
4311+
return nullptr;
4312+
return make<IntegerCastExpr>(T, N);
43414313
}
43424314
}
43434315
}

test/test_demangle.pass.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29784,7 +29784,9 @@ const char* cases[][2] =
2978429784
{"_ZNK1xMUlTyT_E_clIiEEDaS_", "auto x::'lambda'<typename $T>($T)::operator()<int>(x) const"},
2978529785
{"_ZNK1xMUlTnPA3_ivE_clILS0_0EEEDav", "auto x::'lambda'<int (*$N) [3]>()::operator()<(int [3])0>() const"},
2978629786
{"_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"},
29787-
{"_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){...}))"},
29787+
{"_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){...}))"},
29788+
{"_ZN1S1fILb1EEEv1XILUlvE_EE", "void S::f<true>(X<[](){...}>)"},
29789+
{"_ZN1S1fILb1EEEv1XILUlvE0_EE", "void S::f<true>(X<[](){...}>)"},
2978829790
};
2978929791

2979029792
const unsigned N = sizeof(cases) / sizeof(cases[0]);

0 commit comments

Comments
 (0)