llvm.org GIT mirror llvm / bf14f47
[Demangler] copy changes made in libcxxabi's r303718 to ItaniumDemangle git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304053 91177308-0d34-0410-b5e6-96231b3b80d8 Erik Pilkington 2 years ago
1 changed file(s) with 30 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
26112611 first = t0 + 1;
26122612 } break;
26132613 case 'l': {
2614 size_t lambda_pos = db.names.size();
26142615 db.names.push_back(std::string("'lambda'("));
26152616 const char *t0 = first + 2;
26162617 if (first[2] == 'v') {
26172618 db.names.back().first += ')';
26182619 ++t0;
26192620 } else {
2620 const char *t1 = parse_type(t0, last, db);
2621 if (t1 == t0) {
2621 bool is_first_it = true;
2622 while (true) {
2623 long k0 = static_cast(db.names.size());
2624 const char *t1 = parse_type(t0, last, db);
2625 long k1 = static_cast(db.names.size());
2626 if (t1 == t0)
2627 break;
2628 if (k0 >= k1)
2629 return first;
2630 // If the call to parse_type above found a pack expansion
2631 // substitution, then multiple names could have been
2632 // inserted into the name table. Walk through the names,
2633 // appending each onto the lambda's parameter list.
2634 std::for_each(db.names.begin() + k0, db.names.begin() + k1,
2635 [&](typename C::sub_type::value_type &pair) {
2636 if (pair.empty())
2637 return;
2638 auto &lambda = db.names[lambda_pos].first;
2639 if (!is_first_it)
2640 lambda.append(", ");
2641 is_first_it = false;
2642 lambda.append(pair.move_full());
2643 });
2644 db.names.erase(db.names.begin() + k0, db.names.end());
2645 t0 = t1;
2646 }
2647 if (is_first_it) {
26222648 if (!db.names.empty())
26232649 db.names.pop_back();
26242650 return first;
26252651 }
2626 if (db.names.size() < 2)
2627 return first;
2628 auto tmp = db.names.back().move_full();
2629 db.names.pop_back();
2630 db.names.back().first.append(tmp);
2631 t0 = t1;
2632 while (true) {
2633 t1 = parse_type(t0, last, db);
2634 if (t1 == t0)
2635 break;
2636 if (db.names.size() < 2)
2637 return first;
2638 tmp = db.names.back().move_full();
2639 db.names.pop_back();
2640 if (!tmp.empty()) {
2641 db.names.back().first.append(", ");
2642 db.names.back().first.append(tmp);
2643 }
2644 t0 = t1;
2645 }
2646 if (db.names.empty())
2652 if (db.names.empty() || db.names.size() - 1 != lambda_pos)
26472653 return first;
26482654 db.names.back().first.append(")");
26492655 }
42304236 template string_pair(const char (&s)[N]) : first(s, N - 1) {}
42314237
42324238 size_t size() const { return first.size() + second.size(); }
4239 bool empty() const { return first.empty() && second.empty(); }
42334240 StrT full() const { return first + second; }
42344241 StrT move_full() { return std::move(first) + std::move(second); }
42354242 };