llvm.org GIT mirror llvm / e17a816
Demangle: replace custom typedef for std::string with std::string We created a local typedef for `std::basic_string<char, std::char_traits<char>>` which is just `std::string`. Remove the local typedef and propagate the type information through the rest of the demangler. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287470 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 2 years ago
1 changed file(s) with 37 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
141141 int n = snprintf(num, sizeof(num), float_data::spec, value);
142142 if (static_cast(n) >= sizeof(num))
143143 return first;
144 db.names.push_back(typename C::String(num, static_cast(n)));
144 db.names.push_back(std::string(num, static_cast(n)));
145145 first = t + 1;
146146 }
147147 }
164164 return first;
165165 }
166166 if (static_cast(last - t) >= n) {
167 typename C::String r(t, n);
167 std::string r(t, n);
168168 if (r.substr(0, 10) == "_GLOBAL__N")
169169 db.names.push_back("(anonymous namespace)");
170170 else
485485 db.names.push_back(temp);
486486 first = t + 1;
487487 } else {
488 db.names.push_back(typename C::String(first, t + 1));
488 db.names.push_back(std::string(first, t + 1));
489489 first = t + 1;
490490 db.fix_forward_references = true;
491491 }
656656 const char *t = parse_template_param(first + 2, last, db);
657657 size_t k1 = db.names.size();
658658 if (t != first + 2) {
659 typename C::String tmp("sizeof...(");
659 std::string tmp("sizeof...(");
660660 size_t k = k0;
661661 if (k != k1) {
662662 tmp += db.names[k].move_full();
691691 const char *t = parse_cv_qualifiers(first + 2, last, cv);
692692 const char *t1 = parse_number(t, last);
693693 if (t1 != last && *t1 == '_') {
694 db.names.push_back("fp" + typename C::String(t, t1));
694 db.names.push_back("fp" + std::string(t, t1));
695695 first = t1 + 1;
696696 }
697697 } else if (first[1] == 'L') {
702702 const char *t = parse_cv_qualifiers(t0, last, cv);
703703 const char *t1 = parse_number(t, last);
704704 if (t1 != last && *t1 == '_') {
705 db.names.push_back("fp" + typename C::String(t, t1));
705 db.names.push_back("fp" + std::string(t, t1));
706706 first = t1 + 1;
707707 }
708708 }
11461146 if (db.names.empty())
11471147 return first;
11481148 db.names.back().first += db.names.back().second;
1149 db.names.back().second = typename C::String();
1149 db.names.back().second = std::string();
11501150 db.names.back().first.append("(");
11511151 bool first_expr = true;
11521152 while (*t != 'E') {
12551255 }
12561256 if (*t != 'E')
12571257 return first;
1258 typename C::String init_list;
1258 std::string init_list;
12591259 if (has_init) {
12601260 if (db.names.empty())
12611261 return first;
12661266 return first;
12671267 auto type = db.names.back().move_full();
12681268 db.names.pop_back();
1269 typename C::String expr_list;
1269 std::string expr_list;
12701270 if (has_expr_list) {
12711271 if (db.names.empty())
12721272 return first;
12731273 expr_list = db.names.back().move_full();
12741274 db.names.pop_back();
12751275 }
1276 typename C::String r;
1276 std::string r;
12771277 if (parsed_gs)
12781278 r = "::";
12791279 if (is_array)
13941394 const char *t1 = parse_type(t, last, db);
13951395 if (t1 != t) {
13961396 t = t1;
1397 typename C::String sig("(");
1397 std::string sig("(");
13981398 int ref_qual = 0;
13991399 while (true) {
14001400 if (t == last) {
15101510 return first;
15111511 if (db.names.back().second.substr(0, 2) == " [")
15121512 db.names.back().second.erase(0, 1);
1513 db.names.back().second.insert(
1514 0, " [" + typename C::String(first + 1, t) + "]");
1513 db.names.back().second.insert(0,
1514 " [" + std::string(first + 1, t) + "]");
15151515 first = t2;
15161516 }
15171517 }
15841584 if (t1 != t) {
15851585 if (db.names.empty())
15861586 return first;
1587 db.names.back().first +=
1588 " vector[" + typename C::String(num, sz) + "]";
1587 db.names.back().first += " vector[" + std::string(num, sz) + "]";
15891588 first = t1;
15901589 }
15911590 } else {
15921591 ++t;
1593 db.names.push_back("pixel vector[" + typename C::String(num, sz) +
1594 "]");
1592 db.names.push_back("pixel vector[" + std::string(num, sz) + "]");
15951593 first = t;
15961594 }
15971595 }
15981596 } else {
1599 typename C::String num;
1597 std::string num;
16001598 const char *t1 = first + 2;
16011599 if (*t1 != '_') {
16021600 const char *t = parse_expression(t1, last, db);
23102308
23112309 template
23122310 static const char *parse_integer_literal(const char *first, const char *last,
2313 const typename C::String &lit, C &db) {
2311 const std::string &lit, C &db) {
23142312 const char *t = parse_number(first, last);
23152313 if (t != first && t != last && *t == 'E') {
23162314 if (lit.size() > 3)
24712469 if (n != t && n != last && *n == 'E') {
24722470 if (db.names.empty())
24732471 return first;
2474 db.names.back() = "(" + db.names.back().move_full() + ")" +
2475 typename C::String(t, n);
2472 db.names.back() =
2473 "(" + db.names.back().move_full() + ")" + std::string(t, n);
24762474 first = n + 1;
24772475 break;
24782476 }
24872485 return first;
24882486 }
24892487
2490 template static String base_name(String &s) {
2488 static std::string base_name(std::string &s) {
24912489 if (s.empty())
24922490 return s;
24932491 if (s == "std::string") {
25132511 unsigned c = 1;
25142512 while (true) {
25152513 if (--pe == pf)
2516 return String();
2514 return std::string();
25172515 if (pe[-1] == '<') {
25182516 if (--c == 0) {
25192517 --pe;
25242522 }
25252523 }
25262524 if (pe - pf <= 1)
2527 return String();
2525 return std::string();
25282526 const char *p0 = pe - 1;
25292527 for (; p0 != pf; --p0) {
25302528 if (*p0 == ':') {
25322530 break;
25332531 }
25342532 }
2535 return String(p0, pe);
2533 return std::string(p0, pe);
25362534 }
25372535
25382536 // ::= C1 # complete object constructor
25972595 char type = first[1];
25982596 switch (type) {
25992597 case 't': {
2600 db.names.push_back(typename C::String("'unnamed"));
2598 db.names.push_back(std::string("'unnamed"));
26012599 const char *t0 = first + 2;
26022600 if (t0 == last) {
26032601 db.names.pop_back();
26182616 first = t0 + 1;
26192617 } break;
26202618 case 'l': {
2621 db.names.push_back(typename C::String("'lambda'("));
2619 db.names.push_back(std::string("'lambda'("));
26222620 const char *t0 = first + 2;
26232621 if (first[2] == 'v') {
26242622 db.names.back().first += ')';
28082806
28092807 template
28102808 static const char *parse_prefix_expression(const char *first, const char *last,
2811 const typename C::String &op,
2809 const std::string &op,
28122810 C &db) {
28132811 const char *t1 = parse_expression(first, last, db);
28142812 if (t1 != first) {
28222820
28232821 template
28242822 static const char *parse_binary_expression(const char *first, const char *last,
2825 const typename C::String &op,
2823 const std::string &op,
28262824 C &db) {
28272825 const char *t1 = parse_expression(first, last, db);
28282826 if (t1 != first) {
30133011 if (db.names.empty())
30143012 return first;
30153013 db.names.back().first =
3016 (parsed_gs ? typename C::String("::") : typename C::String()) +
3017 "delete[] " + db.names.back().move_full();
3014 (parsed_gs ? std::string("::") : std::string()) + "delete[] " +
3015 db.names.back().move_full();
30183016 first = t1;
30193017 }
30203018 } break;
30323030 if (db.names.empty())
30333031 return first;
30343032 db.names.back().first =
3035 (parsed_gs ? typename C::String("::") : typename C::String()) +
3036 "delete " + db.names.back().move_full();
3033 (parsed_gs ? std::string("::") : std::string()) + "delete " +
3034 db.names.back().move_full();
30373035 first = t1;
30383036 }
30393037 } break;
34413439 if (db.tag_templates)
34423440 db.template_param.back().clear();
34433441 const char *t = first + 1;
3444 typename C::String args("<");
3442 std::string args("<");
34453443 while (*t != 'E') {
34463444 if (db.tag_templates)
34473445 db.template_param.emplace_back(db.names.get_allocator());
40344032 save_value sb2(db.tag_templates);
40354033 db.tag_templates = false;
40364034 const char *t2;
4037 typename C::String ret2;
4035 std::string ret2;
40384036 if (db.names.empty())
40394037 return first;
4040 const typename C::String &nm = db.names.back().first;
4038 const std::string &nm = db.names.back().first;
40414039 if (nm.empty())
40424040 return first;
40434041 if (!db.parsed_ctor_dtor_cv && ends_with_template_args) {
40694067 if (t2 == t)
40704068 break;
40714069 if (k1 > k0) {
4072 typename C::String tmp;
4070 std::string tmp;
40734071 for (size_t k = k0; k < k1; ++k) {
40744072 if (!tmp.empty())
40754073 tmp += ", ";
41604158 if (first != last && *first == '.') {
41614159 if (db.names.empty())
41624160 return first;
4163 db.names.back().first += " (" + typename C::String(first, last) + ")";
4161 db.names.back().first += " (" + std::string(first, last) + ")";
41644162 first = last;
41654163 }
41664164 return first;
42254223 };
42264224
42274225 struct Db {
4228 typedef std::basic_string>
4229 String;
4230 typedef VectorString>> sub_type;
4226 typedef Vectorstd::string>> sub_type;
42314227 typedef Vector template_param_type;
42324228 sub_type names;
42334229 template_param_type subs;