Home | History | Annotate | Download | only in src

Lines Matching defs:Db

37     const char* parse_type(const char* first, const char* last, C& db);
39 const char* parse_encoding(const char* first, const char* last, C& db);
41 const char* parse_name(const char* first, const char* last, C& db,
44 const char* parse_expression(const char* first, const char* last, C& db);
46 const char* parse_template_args(const char* first, const char* last, C& db);
48 const char* parse_operator_name(const char* first, const char* last, C& db);
50 const char* parse_unqualified_name(const char* first, const char* last, C& db);
52 const char* parse_decltype(const char* first, const char* last, C& db);
56 print_stack(const C& db)
60 for (auto& s : db.names)
64 for (auto& v : db.subs)
76 for (auto& t : db.template_param)
97 print_state(const char* msg, const char* first, const char* last, const C& db)
103 print_stack(db);
172 parse_floating_number(const char* first, const char* last, C& db)
205 db.names.push_back(typename C::String(num, static_cast<std::size_t>(n)));
216 parse_source_name(const char* first, const char* last, C& db)
235 db.names.push_back("(anonymous namespace)");
237 db.names.push_back(std::move(r));
258 parse_substitution(const char* first, const char* last, C& db)
267 db.names.push_back("std::allocator");
271 db.names.push_back("std::basic_string");
275 db.names.push_back("std::string");
279 db.names.push_back("std::istream");
283 db.names.push_back("std::ostream");
287 db.names.push_back("std::iostream");
291 if (!db.subs.empty())
293 for (const auto& n : db.subs.front())
294 db.names.push_back(n);
318 if (sub < db.subs.size())
320 for (const auto& n : db.subs[sub])
321 db.names.push_back(n);
366 parse_builtin_type(const char* first, const char* last, C& db)
373 db.names.push_back("void");
377 db.names.push_back("wchar_t");
381 db.names.push_back("bool");
385 db.names.push_back("char");
389 db.names.push_back("signed char");
393 db.names.push_back("unsigned char");
397 db.names.push_back("short");
401 db.names.push_back("unsigned short");
405 db.names.push_back("int");
409 db.names.push_back("unsigned int");
413 db.names.push_back("long");
417 db.names.push_back("unsigned long");
421 db.names.push_back("long long");
425 db.names.push_back("unsigned long long");
429 db.names.push_back("__int128");
433 db.names.push_back("unsigned __int128");
437 db.names.push_back("float");
441 db.names.push_back("double");
445 db.names.push_back("long double");
449 db.names.push_back("__float128");
453 db.names.push_back("...");
458 const char*t = parse_source_name(first+1, last, db);
469 db.names.push_back("decimal64");
473 db.names.push_back("decimal128");
477 db.names.push_back("decimal32");
481 db.names.push_back("decimal16");
485 db.names.push_back("char32_t");
489 db.names.push_back("char16_t");
493 db.names.push_back("auto");
497 db.names.push_back("decltype(auto)");
501 db.names.push_back("std::nullptr_t");
544 parse_template_param(const char* first, const char* last, C& db)
552 if (db.template_param.empty())
554 if (!db.template_param.back().empty())
556 for (auto& t : db.template_param.back().front())
557 db.names.push_back(t);
562 db.names.push_back("T_");
564 db.fix_forward_references = true;
576 if (t == last || *t != '_' || db.template_param.empty())
579 if (sub < db.template_param.back().size())
581 for (auto& temp : db.template_param.back()[sub])
582 db.names.push_back(temp);
587 db.names.push_back(typename C::String(first, t+1));
589 db.fix_forward_references = true;
601 parse_const_cast_expr(const char* first, const char* last, C& db)
605 const char* t = parse_type(first+2, last, db);
608 const char* t1 = parse_expression(t, last, db);
611 if (db.names.size() < 2)
613 auto expr = db.names.back().move_full();
614 db.names.pop_back();
615 db.names.back() = "const_cast<" + db.names.back().move_full() + ">(" + expr + ")";
627 parse_dynamic_cast_expr(const char* first, const char* last, C& db)
631 const char* t = parse_type(first+2, last, db);
634 const char* t1 = parse_expression(t, last, db);
637 if (db.names.size() < 2)
639 auto expr = db.names.back().move_full();
640 db.names.pop_back();
641 db.names.back() = "dynamic_cast<" + db.names.back().move_full() + ">(" + expr + ")";
653 parse_reinterpret_cast_expr(const char* first, const char* last, C& db)
657 const char* t = parse_type(first+2, last, db);
660 const char* t1 = parse_expression(t, last, db);
663 if (db.names.size() < 2)
665 auto expr = db.names.back().move_full();
666 db.names.pop_back();
667 db.names.back() = "reinterpret_cast<" + db.names.back().move_full() + ">(" + expr + ")";
679 parse_static_cast_expr(const char* first, const char* last, C& db)
683 const char* t = parse_type(first+2, last, db);
686 const char* t1 = parse_expression(t, last, db);
689 if (db.names.size() < 2)
691 auto expr = db.names.back().move_full();
692 db.names.pop_back();
693 db.names.back() = "static_cast<" + db.names.back().move_full() + ">(" + expr + ")";
705 parse_pack_expansion(const char* first, const char* last, C& db)
709 const char* t = parse_expression(first+2, last, db);
720 parse_sizeof_type_expr(const char* first, const char* last, C& db)
724 const char* t = parse_type(first+2, last, db);
727 if (db.names.empty())
729 db.names.back() = "sizeof (" + db.names.back().move_full() + ")";
740 parse_sizeof_expr_expr(const char* first, const char* last, C& db)
744 const char* t = parse_expression(first+2, last, db);
747 if (db.names.empty())
749 db.names.back() = "sizeof (" + db.names.back().move_full() + ")";
760 parse_sizeof_param_pack_expr(const char* first, const char* last, C& db)
764 size_t k0 = db.names.size();
765 const char* t = parse_template_param(first+2, last, db);
766 size_t k1 = db.names.size();
773 tmp += db.names[k].move_full();
775 tmp += ", " + db.names[k].move_full();
779 db.names.pop_back();
780 db.names.push_back(std::move(tmp));
794 parse_function_param(const char* first, const char* last, C& db)
805 db.names.push_back("fp" + typename C::String(t, t1));
820 db.names.push_back("fp" + typename C::String(t, t1));
833 parse_sizeof_function_param_pack_expr(const char* first, const char* last, C& db)
837 const char* t = parse_function_param(first+2, last, db);
840 if (db.names.empty())
842 db.names.back() = "sizeof...(" + db.names.back().move_full() + ")";
854 parse_typeid_expr(const char* first, const char* last, C& db)
860 t = parse_expression(first+2, last, db);
862 t = parse_type(first+2, last, db);
865 if (db.names.empty())
867 db.names.back() = "typeid(" + db.names.back().move_full() + ")";
878 parse_throw_expr(const char* first, const char* last, C& db)
882 const char* t = parse_expression(first+2, last, db);
885 if (db.names.empty())
887 db.names.back() = "throw " + db.names.back().move_full();
898 parse_dot_star_expr(const char* first, const char* last, C& db)
902 const char* t = parse_expression(first+2, last, db);
905 const char* t1 = parse_expression(t, last, db);
908 if (db.names.size() < 2)
910 auto expr = db.names.back().move_full();
911 db.names.pop_back();
912 db.names.back().first += ".*" + expr;
924 parse_simple_id(const char* first, const char* last, C& db)
928 const char* t = parse_source_name(first, last, db);
931 const char* t1 = parse_template_args(t, last, db);
934 if (db.names.size() < 2)
936 auto args = db.names.back().move_full();
937 db.names.pop_back();
938 db.names.back().first += std::move(args);
954 parse_unresolved_type(const char* first, const char* last, C& db)
963 size_t k0 = db.names.size();
964 t = parse_template_param(first, last, db);
965 size_t k1 = db.names.size();
968 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
974 db.names.pop_back();
979 t = parse_decltype(first, last, db);
982 if (db.names.empty())
984 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
989 t = parse_substitution(first, last, db);
996 t = parse_unqualified_name(first+2, last, db);
999 if (db.names.empty())
1001 db.names.back().first.insert(0, "std::");
1002 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
1018 parse_destructor_name(const char* first, const char* last, C& db)
1022 const char* t = parse_unresolved_type(first, last, db);
1024 t = parse_simple_id(first, last, db);
1027 if (db.names.empty())
1029 db.names.back().first.insert(0, "~");
1046 parse_base_unresolved_name(const char* first, const char* last, C& db)
1054 const char* t = parse_operator_name(first+2, last, db);
1057 first = parse_template_args(t, last, db);
1060 if (db.names.size() < 2)
1062 auto args = db.names.back().move_full();
1063 db.names.pop_back();
1064 db.names.back().first += std::move(args);
1070 const char* t = parse_destructor_name(first+2, last, db);
1077 const char* t = parse_simple_id(first, last, db);
1080 t = parse_operator_name(first, last, db);
1083 first = parse_template_args(t, last, db);
1086 if (db.names.size() < 2)
1088 auto args = db.names.back().move_full();
1089 db.names.pop_back();
1090 db.names.back().first += std::move(args);
1105 parse_unresolved_qualifier_level(const char* first, const char* last, C& db)
1107 return parse_simple_id(first, last, db);
1122 parse_unresolved_name(const char* first, const char* last, C& db)
1133 const char* t2 = parse_base_unresolved_name(t, last, db);
1138 if (db.names.empty())
1140 db.names.back().first.insert(0, "::");
1149 const char* t1 = parse_unresolved_type(t, last, db);
1153 t1 = parse_template_args(t, last, db);
1156 if (db.names.size() < 2)
1158 auto args = db.names.back().move_full();
1159 db.names.pop_back();
1160 db.names.back().first += std::move(args);
1164 db.names.pop_back();
1170 t1 = parse_unresolved_qualifier_level(t, last, db);
1171 if (t1 == t || t1 == last || db.names.size() < 2)
1173 auto s = db.names.back().move_full();
1174 db.names.pop_back();
1175 db.names.back().first += "::" + std::move(s);
1179 t1 = parse_base_unresolved_name(t, last, db);
1182 if (!db.names.empty())
1183 db.names.pop_back();
1186 if (db.names.size() < 2)
1188 auto s = db.names.back().move_full();
1189 db.names.pop_back();
1190 db.names.back().first += "::" + std::move(s);
1196 const char* t1 = parse_unresolved_type(t, last, db);
1200 t1 = parse_template_args(t, last, db);
1203 if (db.names.size() < 2)
1205 auto args = db.names.back().move_full();
1206 db.names.pop_back();
1207 db.names.back().first += std::move(args);
1210 t1 = parse_base_unresolved_name(t, last, db);
1213 if (!db.names.empty())
1214 db.names.pop_back();
1217 if (db.names.size() < 2)
1219 auto s = db.names.back().move_full();
1220 db.names.pop_back();
1221 db.names.back().first += "::" + std::move(s);
1226 t1 = parse_unresolved_qualifier_level(t, last, db);
1232 if (db.names.empty())
1234 db.names.back().first.insert(0, "::");
1238 t1 = parse_unresolved_qualifier_level(t, last, db);
1239 if (t1 == t || t1 == last || db.names.size() < 2)
1241 auto s = db.names.back().move_full();
1242 db.names.pop_back();
1243 db.names.back().first += "::" + std::move(s);
1247 t1 = parse_base_unresolved_name(t, last, db);
1250 if (!db.names.empty())
1251 db.names.pop_back();
1254 if (db.names.size() < 2)
1256 auto s = db.names.back().move_full();
1257 db.names.pop_back();
1258 db.names.back().first += "::" + std::move(s);
1271 parse_dot_expr(const char* first, const char* last, C& db)
1275 const char* t = parse_expression(first+2, last, db);
1278 const char* t1 = parse_unresolved_name(t, last, db);
1281 if (db.names.size() < 2)
1283 auto name = db.names.back().move_full();
1284 db.names.pop_back();
1285 db.names.back().first += "." + name;
1297 parse_call_expr(const char* first, const char* last, C& db)
1301 const char* t = parse_expression(first+2, last, db);
1306 if (db.names.empty())
1308 db.names.back().first += db.names.back().second;
1309 db.names.back().second = typename C::String();
1310 db.names.back().first.append("(");
1314 const char* t1 = parse_expression(t, last, db);
1317 if (db.names.empty())
1319 auto tmp = db.names.back().move_full();
1320 db.names.pop_back();
1323 if (db.names.empty())
1327 db.names.back().first.append(", ");
1330 db.names.back().first.append(tmp);
1335 if (db.names.empty())
1337 db.names.back().first.append(")");
1352 parse_new_expr(const char* first, const char* last, C& db)
1373 const char* t1 = parse_expression(t, last, db);
1379 if (db.names.empty())
1381 auto tmp = db.names.back().move_full();
1382 db.names.pop_back();
1385 if (db.names.empty())
1387 db.names.back().first.append(", ");
1388 db.names.back().first.append(tmp);
1395 const char* t1 = parse_type(t, last, db);
1407 t1 = parse_expression(t, last, db);
1412 if (db.names.empty())
1414 auto tmp = db.names.back().move_full();
1415 db.names.pop_back();
1418 if (db.names.empty())
1420 db.names.back().first.append(", ");
1421 db.names.back().first.append(tmp);
1433 if (db.names.empty())
1435 init_list = db.names.back().move_full();
1436 db.names.pop_back();
1438 if (db.names.empty())
1440 auto type = db.names.back().move_full();
1441 db.names.pop_back();
1445 if (db.names.empty())
1447 expr_list = db.names.back().move_full();
1448 db.names.pop_back();
1462 db.names.push_back(std::move(r));
1474 parse_conversion_expr(const char* first, const char* last, C& db)
1478 bool try_to_parse_template_args = db.try_to_parse_template_args;
1479 db.try_to_parse_template_args = false;
1480 const char* t = parse_type(first+2, last, db);
1481 db.try_to_parse_template_args = try_to_parse_template_args;
1486 const char* t1 = parse_expression(t, last, db);
1497 db.names.emplace_back();
1503 const char* t1 = parse_expression(t, last, db);
1508 if (db.names.empty())
1510 auto tmp = db.names.back().move_full();
1511 db.names.pop_back();
1514 if (db.names.empty())
1516 db.names.back().first.append(", ");
1517 db.names.back().first.append(tmp);
1526 if (db.names.size() < 2)
1528 auto tmp = db.names.back().move_full();
1529 db.names.pop_back();
1530 db.names.back() = "(" + db.names.back().move_full() + ")(" + tmp + ")";
1541 parse_arrow_expr(const char* first, const char* last, C& db)
1545 const char* t = parse_expression(first+2, last, db);
1548 const char* t1 = parse_expression(t, last, db);
1551 if (db.names.size() < 2)
1553 auto tmp = db.names.back().move_full();
1554 db.names.pop_back();
1555 db.names.back().first += "->";
1556 db.names.back().first += tmp;
1571 parse_function_type(const char* first, const char* last, C& db)
1585 const char* t1 = parse_type(t, last, db);
1595 db.names.pop_back();
1620 size_t k0 = db.names.size();
1621 t1 = parse_type(t, last, db);
1622 size_t k1 = db.names.size();
1629 sig += db.names[k].move_full();
1632 db.names.pop_back();
1645 if (db.names.empty())
1647 db.names.back().first += " ";
1648 db.names.back().second.insert(0, sig);
1660 parse_pointer_to_member_type(const char* first, const char* last, C& db)
1664 const char* t = parse_type(first+1, last, db);
1667 const char* t2 = parse_type(t, last, db);
1670 if (db.names.size() < 2)
1672 auto func = std::move(db.names.back());
1673 db.names.pop_back();
1674 auto class_type = std::move(db.names.back());
1677 db.names.back().first = std::move(func.first) + "(" + class_type.move_full() + "::*";
1678 db.names.back().second = ")" + std::move(func.second);
1682 db.names.back().first = std::move(func.first) + " " + class_type.move_full() + "::*";
1683 db.names.back().second = std::move(func.second);
1697 parse_array_type(const char* first, const char* last, C& db)
1703 const char* t = parse_type(first+2, last, db);
1706 if (db.names.empty())
1708 if (db.names.back().second.substr(0, 2) == " [")
1709 db.names.back().second.erase(0, 1);
1710 db.names.back().second.insert(0, " []");
1719 const char* t2 = parse_type(t+1, last, db);
1722 if (db.names.empty())
1724 if (db.names.back().second.substr(0, 2) == " [")
1725 db.names.back().second.erase(0, 1);
1726 db.names.back().second.insert(0, " [" + typename C::String(first+1, t) + "]");
1733 const char* t = parse_expression(first+1, last, db);
1736 const char* t2 = parse_type(++t, last, db);
1739 if (db.names.size() < 2)
1741 auto type = std::move(db.names.back());
1742 db.names.pop_back();
1743 auto expr = std::move(db.names.back());
1744 db.names.back().first = std::move(type.first);
1747 db.names.back().second = " [" + expr.move_full() + "]" + std::move(type.second);
1761 parse_decltype(const char* first, const char* last, C& db)
1770 const char* t = parse_expression(first+2, last, db);
1773 if (db.names.empty())
1775 db.names.back() = "decltype(" + db.names.back().move_full() + ")";
1794 parse_vector_type(const char* first, const char* last, C& db)
1809 const char* t1 = parse_type(t, last, db);
1812 if (db.names.empty())
1814 db.names.back().first += " vector[" + typename C::String(num, sz) + "]";
1821 db.names.push_back("pixel vector[" + typename C::String(num, sz) + "]");
1832 const char* t = parse_expression(t1, last, db);
1835 if (db.names.empty())
1837 num = db.names.back().move_full();
1838 db.names.pop_back();
1844 const char* t = parse_type(t1, last, db);
1847 if (db.names.empty())
1849 db.names.back().first += " vector[" + num + "]";
1883 parse_type(const char* first, const char* last, C& db)
1898 size_t k0 = db.names.size();
1899 const char* t1 = parse_type(t, last, db);
1900 size_t k1 = db.names.size();
1904 db.subs.pop_back();
1905 db.subs.emplace_back(db.names.get_allocator());
1910 size_t p = db.names[k].second.size();
1911 if (db.names[k].second[p-2] == '&')
1913 else if (db.names[k].second.back() == '&')
1917 db.names[k].second.insert(p, " const");
1922 db.names[k].second.insert(p, " volatile");
1926 db.names[k].second.insert(p, " restrict");
1931 db.names[k].first.append(" const");
1933 db.names[k].first.append(" volatile");
1935 db.names[k].first.append(" restrict");
1937 db.subs.back().push_back(db.names[k]);
1946 const char* t = parse_builtin_type(first, last, db);
1956 t = parse_array_type(first, last, db);
1959 if (db.names.empty())
1962 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
1966 t = parse_type(first+1, last, db);
1969 if (db.names.empty())
1971 db.names.back().first.append(" complex");
1973 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
1977 t = parse_function_type(first, last, db);
1980 if (db.names.empty())
1983 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
1987 t = parse_type(first+1, last, db);
1990 if (db.names.empty())
1992 db.names.back().first.append(" imaginary");
1994 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
1998 t = parse_pointer_to_member_type(first, last, db);
2001 if (db.names.empty())
2004 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
2009 size_t k0 = db.names.size();
2010 t = parse_type(first+1, last, db);
2011 size_t k1 = db.names.size();
2014 db.subs.emplace_back(db.names.get_allocator());
2017 if (db.names[k].second.substr(0, 2) == " [")
2019 db.names[k].first += " (";
2020 db.names[k].second.insert(0, ")");
2022 else if (db.names[k].second.front() == '(')
2024 db.names[k].first += "(";
2025 db.names[k].second.insert(0, ")");
2027 db.names[k].first.append("&&");
2028 db.subs.back().push_back(db.names[k]);
2036 size_t k0 = db.names.size();
2037 t = parse_type(first+1, last, db);
2038 size_t k1 = db.names.size();
2041 db.subs.emplace_back(db.names.get_allocator());
2044 if (db.names[k].second.substr(0, 2) == " [")
2046 db.names[k].first += " (";
2047 db.names[k].second.insert(0, ")");
2049 else if (db.names[k].second.front() == '(')
2051 db.names[k].first += "(";
2052 db.names[k].second.insert(0, ")");
2054 if (first[1] != 'U' || db.names[k].first.substr(0, 12) != "objc_object<")
2056 db.names[k].first.append("*");
2060 db.names[k].first.replace(0, 11, "id");
2062 db.subs.back().push_back(db.names[k]);
2070 size_t k0 = db.names.size();
2071 t = parse_type(first+1, last, db);
2072 size_t k1 = db.names.size();
2075 db.subs.emplace_back(db.names.get_allocator());
2078 if (db.names[k].second.substr(0, 2) == " [")
2080 db.names[k].first += " (";
2081 db.names[k].second.insert(0, ")");
2083 else if (db.names[k].second.front() == '(')
2085 db.names[k].first += "(";
2086 db.names[k].second.insert(0, ")");
2088 db.names[k].first.append("&");
2089 db.subs.back().push_back(db.names[k]);
2097 size_t k0 = db.names.size();
2098 t = parse_template_param(first, last, db);
2099 size_t k1 = db.names.size();
2102 db.subs.emplace_back(db.names.get_allocator());
2104 db.subs.back().push_back(db.names[k]);
2105 if (db.try_to_parse_template_args && k1 == k0+1)
2107 const char* t1 = parse_template_args(t, last, db);
2110 auto args = db.names.back().move_full();
2111 db.names.pop_back();
2112 db.names.back().first += std::move(args);
2113 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
2124 t = parse_source_name(first+1, last, db);
2127 const char* t2 = parse_type(t, last, db);
2130 if (db.names.size() < 2)
2132 auto type = db.names.back().move_full();
2133 db.names.pop_back();
2134 if (db.names.back().first.substr(0, 9) != "objcproto")
2136 db.names.back() = type + " " + db.names.back().move_full();
2140 auto proto = db.names.back().move_full();
2141 db.names.pop_back();
2142 t = parse_source_name(proto.data() + 9, proto.data() + proto.size(), db);
2145 db.names.back() = type + "<" + db.names.back().move_full() + ">";
2149 db.names.push_back(type + " " + proto);
2152 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
2161 t = parse_name(first, last, db);
2164 if (db.names.empty())
2166 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
2172 t = parse_substitution(first, last, db);
2178 t = parse_template_args(first, last, db);
2181 if (db.names.size() < 2)
2183 auto template_args = db.names.back().move_full();
2184 db.names.pop_back();
2185 db.names.back().first += template_args;
2187 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
2200 size_t k0 = db.names.size();
2201 t = parse_type(first+2, last, db);
2202 size_t k1 = db.names.size();
2205 db.subs.emplace_back(db.names.get_allocator());
2207 db.subs.back().push_back(db.names[k]);
2215 t = parse_decltype(first, last, db);
2218 if (db.names.empty())
2220 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
2226 t = parse_vector_type(first, last, db);
2229 if (db.names.empty())
2231 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
2242 t = parse_builtin_type(first, last, db);
2249 t = parse_name(first, last, db);
2252 if (db.names.empty())
2254 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
2322 parse_operator_name(const char* first, const char* last, C& db)
2332 db.names.push_back("operator&&");
2337 db.names.push_back("operator&");
2341 db.names.push_back("operator&=");
2345 db.names.push_back("operator=");
2354 db.names.push_back("operator()");
2358 db.names.push_back("operator,");
2362 db.names.push_back("operator~");
2367 bool try_to_parse_template_args = db.try_to_parse_template_args;
2368 db.try_to_parse_template_args = false;
2369 const char* t = parse_type(first+2, last, db);
2370 db.try_to_parse_template_args = try_to_parse_template_args;
2373 if (db.names.empty())
2375 db.names.back().first.insert(0, "operator ");
2376 db.parsed_ctor_dtor_cv = true;
2387 db.names.push_back("operator delete[]");
2391 db.names.push_back("operator*");
2395 db.names.push_back("operator delete");
2399 db.names.push_back("operator/");
2403 db.names.push_back("operator/=");
2412 db.names.push_back("operator^");
2416 db.names.push_back("operator^=");
2420 db.names.push_back("operator==");
2429 db.names.push_back("operator>=");
2433 db.names.push_back("operator>");
2441 db.names.push_back("operator[]");
2449 db.names.push_back("operator<=");
2454 const char* t = parse_source_name(first+2, last, db);
2457 if (db.names.empty())
2459 db.names.back().first.insert(0, "operator\"\" ");
2465 db.names.push_back("operator<<");
2469 db.names.push_back("operator<<=");
2473 db.names.push_back("operator<");
2482 db.names.push_back("operator-");
2486 db.names.push_back("operator-=");
2490 db.names.push_back("operator*");
2494 db.names.push_back("operator*=");
2498 db.names.push_back("operator--");
2507 db.names.push_back("operator new[]");
2511 db.names.push_back("operator!=");
2515 db.names.push_back("operator-");
2519 db.names.push_back("operator!");
2523 db.names.push_back("operator new");
2532 db.names.push_back("operator||");
2536 db.names.push_back("operator|");
2540 db.names.push_back("operator|=");
2549 db.names.push_back("operator->*");
2553 db.names.push_back("operator+");
2557 db.names.push_back("operator+=");
2561 db.names.push_back("operator++");
2565 db.names.push_back("operator+");
2569 db.names.push_back("operator->");
2577 db.names.push_back("operator?");
2585 db.names.push_back("operator%");
2589 db.names.push_back("operator%=");
2593 db.names.push_back("operator>>");
2597 db.names.push_back("operator>>=");
2605 const char* t = parse_source_name(first+2, last, db);
2608 if (db.names.empty())
2610 db.names.back().first.insert(0, "operator ");
2622 parse_integer_literal(const char* first, const char* last, const typename C::String& lit, C& db)
2628 db.names.push_back("(" + lit + ")");
2630 db.names.emplace_back();
2633 db.names.back().first += '-';
2636 db.names.back().first.append(first, t);
2638 db.names.back().first += lit;
2653 parse_expr_primary(const char* first, const char* last, C& db)
2661 const char* t = parse_integer_literal(first+2, last, "wchar_t", db);
2672 db.names.push_back("false");
2676 db.names.push_back("true");
2684 const char* t = parse_integer_literal(first+2, last, "char", db);
2691 const char* t = parse_integer_literal(first+2, last, "signed char", db);
2698 const char* t = parse_integer_literal(first+2, last, "unsigned char", db);
2705 const char* t = parse_integer_literal(first+2, last, "short", db);
2712 const char* t = parse_integer_literal(first+2, last, "unsigned short", db);
2719 const char* t = parse_integer_literal(first+2, last, "", db);
2726 const char* t = parse_integer_literal(first+2, last, "u", db);
2733 const char* t = parse_integer_literal(first+2, last, "l", db);
2740 const char* t = parse_integer_literal(first+2, last, "ul", db);
2747 const char* t = parse_integer_literal(first+2, last, "ll", db);
2754 const char* t = parse_integer_literal(first+2, last, "ull", db);
2761 const char* t = parse_integer_literal(first+2, last, "__int128", db);
2768 const char* t = parse_integer_literal(first+2, last, "unsigned __int128", db);
2775 const char* t = parse_floating_number<float>(first+2, last, db);
2782 const char* t = parse_floating_number<double>(first+2, last, db);
2789 const char* t = parse_floating_number<long double>(first+2, last, db);
2797 const char* t = parse_encoding(first+3, last, db);
2809 const char* t = parse_type(first+1, last, db);
2819 if (db.names.empty())
2821 db.names.back() = "(" + db.names.back().move_full() + ")" + typename C::String(t, n);
2908 parse_ctor_dtor_name(const char* first, const char* last, C& db)
2910 if (last-first >= 2 && !db.names.empty())
2921 if (db.names.empty())
2923 db.names.push_back(base_name(db.names.back().first));
2925 db.parsed_ctor_dtor_cv = true;
2936 if (db.names.empty())
2938 db.names.push_back("~" + base_name(db.names.back().first));
2940 db.parsed_ctor_dtor_cv = true;
2958 parse_unnamed_type_name(const char* first, const char* last, C& db)
2967 db.names.push_back(typename C::String("'unnamed"));
2971 db.names.pop_back();
2979 db.names.back().first.append(t0, t1);
2982 db.names.back().first.push_back('\'');
2985 db.names.pop_back();
2993 db.names.push_back(typename C::String("'lambda'("));
2997 db.names.back().first += ')';
3002 const char* t1 = parse_type(t0, last, db);
3005 db.names.pop_back();
3008 if (db.names.size() < 2)
3010 auto tmp = db.names.back().move_full();
3011 db.names.pop_back();
3012 db.names.back().first.append(tmp);
3016 t1 = parse_type(t0, last, db);
3019 if (db.names.size() < 2)
3021 tmp = db.names.back().move_full();
3022 db.names.pop_back();
3025 db.names.back().first.append(", ");
3026 db.names.back().first.append(tmp);
3030 db.names.back().first.append(")");
3034 db.names.pop_back();
3040 db.names.pop_back();
3048 db.names.back().first.insert(db.names.back().first.begin()+7, t0, t1);
3053 db.names.pop_back();
3071 parse_unqualified_name(const char* first, const char* last, C& db)
3080 t = parse_ctor_dtor_name(first, last, db);
3085 t = parse_unnamed_type_name(first, last, db);
3098 t = parse_source_name(first, last, db);
3103 t = parse_operator_name(first, last, db);
3118 parse_unscoped_name(const char* first, const char* last, C& db)
3131 const char* t1 = parse_unqualified_name(t0, last, db);
3136 if (db.names.empty())
3138 db.names.back().first.insert(0, "std::");
3150 parse_alignof_type(const char* first, const char* last, C& db)
3154 const char* t = parse_type(first+2, last, db);
3157 if (db.names.empty())
3159 db.names.back().first = "alignof (" + db.names.back().move_full() + ")";
3170 parse_alignof_expr(const char* first, const char* last, C& db)
3174 const char* t = parse_expression(first+2, last, db);
3177 if (db.names.empty())
3179 db.names.back().first = "alignof (" + db.names.back().move_full() + ")";
3188 parse_noexcept_expression(const char* first, const char* last, C& db)
3190 const char* t1 = parse_expression(first, last, db);
3193 if (db.names.empty())
3195 db.names.back().first = "noexcept (" + db.names.back().move_full() + ")";
3203 parse_prefix_expression(const char* first, const char* last, const typename C::String& op, C& db)
3205 const char* t1 = parse_expression(first, last, db);
3208 if (db.names.empty())
3210 db.names.back().first = op + "(" + db.names.back().move_full() + ")";
3218 parse_binary_expression(const char* first, const char* last, const typename C::String& op, C& db)
3220 const char* t1 = parse_expression(first, last, db);
3223 const char* t2 = parse_expression(t1, last, db);
3226 if (db.names.size() < 2)
3228 auto op2 = db.names.back().move_full();
3229 db.names.pop_back();
3230 auto op1 = db.names.back().move_full();
3231 auto& nm = db.names.back().first;
3241 db.names.pop_back();
3288 parse_expression(const char* first, const char* last, C& db)
3302 first = parse_expr_primary(first, last, db);
3305 first = parse_template_param(first, last, db);
3308 first = parse_function_param(first, last, db);
3314 t = parse_binary_expression(first+2, last, "&&", db);
3319 t = parse_prefix_expression(first+2, last, "&", db);
3324 t = parse_binary_expression(first+2, last, "&", db);
3329 t = parse_binary_expression(first+2, last, "&=", db);
3334 t = parse_binary_expression(first+2, last, "=", db);
3339 first = parse_alignof_type(first, last, db);
3342 first = parse_alignof_expr(first, last, db);
3350 first = parse_const_cast_expr(first, last, db);
3353 first = parse_call_expr(first, last, db);
3356 t = parse_binary_expression(first+2, last, ",", db);
3361 t = parse_prefix_expression(first+2, last, "~", db);
3366 first = parse_conversion_expr(first, last, db);
3375 const char* t1 = parse_expression(t+2, last, db);
3378 if (db.names.empty())
3380 db.names.back().first = (parsed_gs ? typename C::String("::") : typename C::String()) +
3381 "delete[] " + db.names.back().move_full();
3387 first = parse_dynamic_cast_expr(first, last, db);
3390 t = parse_prefix_expression(first+2, last, "*", db);
3396 const char* t1 = parse_expression(t+2, last, db);
3399 if (db.names.empty())
3401 db.names.back().first = (parsed_gs ? typename C::String("::") : typename C::String()) +
3402 "delete " + db.names.back().move_full();
3408 return parse_unresolved_name(first, last, db);
3410 first = parse_dot_star_expr(first, last, db);
3413 first = parse_dot_expr(first, last, db);
3416 t = parse_binary_expression(first+2, last, "/", db);
3421 t = parse_binary_expression(first+2, last, "/=", db);
3431 t = parse_binary_expression(first+2, last, "^", db);
3436 t = parse_binary_expression(first+2, last, "^=", db);
3441 t = parse_binary_expression(first+2, last, "==", db);
3451 t = parse_binary_expression(first+2, last, ">=", db);
3456 t = parse_binary_expression(first+2, last, ">", db);
3465 const char* t1 = parse_expression(first+2, last, db);
3468 const char* t2 = parse_expression(t1, last, db);
3471 if (db.names.size() < 2)
3473 auto op2 = db.names.back().move_full();
3474 db.names.pop_back();
3475 auto op1 = db.names.back().move_full();
3476 db.names.back() = "(" + op1 + ")[" + op2 + "]";
3480 db.names.pop_back();
3488 t = parse_binary_expression(first+2, last, "<=", db);
3493 t = parse_binary_expression(first+2, last, "<<", db);
3498 t = parse_binary_expression(first+2, last, "<<=", db);
3503 t = parse_binary_expression(first+2, last, "<", db);
3513 t = parse_binary_expression(first+2, last, "-", db);
3518 t = parse_binary_expression(first+2, last, "-=", db);
3523 t = parse_binary_expression(first+2, last, "*", db);
3528 t = parse_binary_expression(first+2, last, "*=", db);
3535 t = parse_prefix_expression(first+3, last, "--", db);
3541 const char* t1 = parse_expression(first+2, last, db);
3544 if (db.names.empty())
3546 db.names.back() = "(" + db.names.back().move_full() + ")--";
3558 first = parse_new_expr(first, last, db);
3561 t = parse_binary_expression(first+2, last, "!=", db);
3566 t = parse_prefix_expression(first+2, last, "-", db);
3571 t = parse_prefix_expression(first+2, last, "!", db);
3576 t = parse_noexcept_expression(first+2, last, db);
3586 return parse_unresolved_name(first, last, db);
3588 t = parse_binary_expression(first+2, last, "||", db);
3593 t = parse_binary_expression(first+2, last, "|", db);
3598 t = parse_binary_expression(first+2, last, "|=", db);
3608 t = parse_binary_expression(first+2, last, "->*", db);
3613 t = parse_binary_expression(first+2, last, "+", db);
3618 t = parse_binary_expression(first+2, last, "+=", db);
3625 t = parse_prefix_expression(first+3, last, "++", db);
3631 const char* t1 = parse_expression(first+2, last, db);
3634 if (db.names.empty())
3636 db.names.back() = "(" + db.names.back().move_full() + ")++";
3642 t = parse_prefix_expression(first+2, last, "+", db);
3647 first = parse_arrow_expr(first, last, db);
3654 const char* t1 = parse_expression(first+2, last, db);
3657 const char* t2 = parse_expression(t1, last, db);
3660 const char* t3 = parse_expression(t2, last, db);
3663 if (db.names.size() < 3)
3665 auto op3 = db.names.back().move_full();
3666 db.names.pop_back();
3667 auto op2 = db.names.back().move_full();
3668 db.names.pop_back();
3669 auto op1 = db.names.back().move_full();
3670 db.names.back() = "(" + op1 + ") ? (" + op2 + ") : (" + op3 + ")";
3675 db.names.pop_back();
3676 db.names.pop_back();
3680 db.names.pop_back();
3688 first = parse_reinterpret_cast_expr(first, last, db);
3691 t = parse_binary_expression(first+2, last, "%", db);
3696 t = parse_binary_expression(first+2, last, "%=", db);
3701 t = parse_binary_expression(first+2, last, ">>", db);
3706 t = parse_binary_expression(first+2, last, ">>=", db);
3716 first = parse_static_cast_expr(first, last, db);
3719 first = parse_pack_expansion(first, last, db);
3722 return parse_unresolved_name(first, last, db);
3724 first = parse_sizeof_type_expr(first, last, db);
3727 first = parse_sizeof_expr_expr(first, last, db);
3735 first = parse_sizeof_param_pack_expr(first, last, db);
3738 first = parse_sizeof_function_param_pack_expr(first, last, db);
3750 first = parse_typeid_expr(first, last, db);
3753 db.names.push_back("throw");
3757 first = parse_throw_expr(first, last, db);
3770 return parse_unresolved_name(first, last, db);
3784 parse_template_arg(const char* first, const char* last, C& db)
3792 t = parse_expression(first+1, last, db);
3805 const char* t1 = parse_template_arg(t, last, db);
3816 t = parse_encoding(first+2, last, db);
3821 first = parse_expr_primary(first, last, db);
3825 first = parse_type(first, last, db);
3837 parse_template_args(const char* first, const char* last, C& db)
3841 if (db.tag_templates)
3842 db.template_param.back().clear();
3847 if (db.tag_templates)
3848 db.template_param.emplace_back(db.names.get_allocator());
3849 size_t k0 = db.names.size();
3850 const char* t1 = parse_template_arg(t, last, db);
3851 size_t k1 = db.names.size();
3852 if (db.tag_templates)
3853 db.template_param.pop_back();
3856 if (db.tag_templates)
3858 db.template_param.back().emplace_back(db.names.get_allocator());
3860 db.template_param.back().back().push_back(db.names[k]);
3866 args += db.names[k].move_full();
3869 db.names.pop_back();
3877 db.names.push_back(std::move(args));
3901 parse_nested_name(const char* first, const char* last, C& db,
3910 db.ref = 0;
3913 db.ref = 1;
3918 db.ref = 2;
3921 db.names.emplace_back();
3925 db.names.back().first = "std";
3929 db.names.pop_back();
3943 t1 = parse_substitution(t0, last, db);
3946 auto name = db.names.back().move_full();
3947 db.names.pop_back();
3948 if (!db.names.back().first.empty())
3950 db.names.back().first += "::" + name;
3951 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
3954 db.names.back().first = name;
3962 t1 = parse_template_param(t0, last, db);
3965 auto name = db.names.back().move_full();
3966 db.names.pop_back();
3967 if (!db.names.back().first.empty())
3968 db.names.back().first += "::" + name;
3970 db.names.back().first = name;
3971 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
3981 t1 = parse_decltype(t0, last, db);
3984 auto name = db.names.back().move_full();
3985 db.names.pop_back();
3986 if (!db.names.back().first.empty())
3987 db.names.back().first += "::" + name;
3989 db.names.back().first = name;
3990 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
3998 t1 = parse_template_args(t0, last, db);
4001 auto name = db.names.back().move_full();
4002 db.names.pop_back();
4003 db.names.back().first += name;
4004 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
4017 t1 = parse_unqualified_name(t0, last, db);
4020 auto name = db.names.back().move_full();
4021 db.names.pop_back();
4022 if (!db.names.back().first.empty())
4023 db.names.back().first += "::" + name;
4025 db.names.back().first = name;
4026 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
4035 db.cv = cv;
4036 if (pop_subs && !db.subs.empty())
4037 db.subs.pop_back();
4087 parse_local_name(const char* first, const char* last, C& db,
4092 const char* t = parse_encoding(first+1, last, db);
4099 if (db.names.empty())
4101 db.names.back().first.append("::string literal");
4110 t1 = parse_name(t, last, db,
4114 if (db.names.size() < 2)
4116 auto name = db.names.back().move_full();
4117 db.names.pop_back();
4118 db.names.back().first.append("::");
4119 db.names.back().first.append(name);
4123 db.names.pop_back();
4129 const char* t1 = parse_name(t, last, db,
4135 if (db.names.size() < 2)
4137 auto name = db.names.back().move_full();
4138 db.names.pop_back();
4139 db.names.back().first.append("::");
4140 db.names.back().first.append(name);
4143 db.names.pop_back();
4162 parse_name(const char* first, const char* last, C& db,
4175 const char* t1 = parse_nested_name(t0, last, db,
4183 const char* t1 = parse_local_name(t0, last, db,
4191 const char* t1 = parse_unscoped_name(t0, last, db);
4196 if (db.names.empty())
4198 db.subs.push_back(typename C::sub_type(1, db.names.back(), db.names.get_allocator()));
4200 t1 = parse_template_args(t0, last, db);
4203 if (db.names.size() < 2)
4205 auto tmp = db.names.back().move_full();
4206 db.names.pop_back();
4207 db.names.back().first += tmp;
4218 t1 = parse_substitution(t0, last, db);
4222 t1 = parse_template_args(t0, last, db);
4225 if (db.names.size() < 2)
4227 auto tmp = db.names.back().move_full();
4228 db.names.pop_back();
4229 db.names.back().first += tmp;
4299 parse_special_name(const char* first, const char* last, C& db)
4311 t = parse_type(first+2, last, db);
4314 if (db.names.empty())
4316 db.names.back().first.insert(0, "vtable for ");
4322 t = parse_type(first+2, last, db);
4325 if (db.names.empty())
4327 db.names.back().first.insert(0, "VTT for ");
4333 t = parse_type(first+2, last, db);
4336 if (db.names.empty())
4338 db.names.back().first.insert(0, "typeinfo for ");
4344 t = parse_type(first+2, last, db);
4347 if (db.names.empty())
4349 db.names.back().first.insert(0, "typeinfo name for ");
4362 t = parse_encoding(t1, last, db);
4365 if (db.names.empty())
4367 db.names.back().first.insert(0, "covariant return thunk to ");
4374 t = parse_type(first+2, last, db);
4380 const char* t1 = parse_type(++t0, last, db);
4383 if (db.names.size() < 2)
4385 auto left = db.names.back().move_full();
4386 db.names.pop_back();
4387 db.names.back().first = "construction vtable for " +
4389 db.names.back().move_full();
4401 t = parse_encoding(t0, last, db);
4404 if (db.names.empty())
4408 db.names.back().first.insert(0, "virtual thunk to ");
4413 db.names.back().first.insert(0, "non-virtual thunk to ");
4426 t = parse_name(first+2, last, db);
4429 if (db.names.empty())
4431 db.names.back().first.insert(0, "guard variable for ");
4437 t = parse_name(first+2, last, db);
4440 if (db.names.empty())
4442 db.names.back().first.insert(0, "reference temporary for ");
4479 parse_encoding(const char* first, const char* last, C& db)
4483 save_value<decltype(db.encoding_depth)> su(db.encoding_depth);
4484 ++db.encoding_depth;
4485 save_value<decltype(db.tag_templates)> sb(db.tag_templates);
4486 if (db.encoding_depth > 1)
4487 db.tag_templates = true;
4492 first = parse_special_name(first, last, db);
4497 const char* t = parse_name(first, last, db,
4499 unsigned cv = db.cv;
4500 unsigned ref = db.ref;
4505 save_value<bool> sb2(db.tag_templates);
4506 db.tag_templates = false;
4509 if (db.names.empty())
4511 const typename C::String& nm = db.names.back().first;
4514 if (!db.parsed_ctor_dtor_cv && ends_with_template_args)
4516 t2 = parse_type(t, last, db);
4519 if (db.names.size() < 2)
4521 auto ret1 = std::move(db.names.back().first);
4522 ret2 = std::move(db.names.back().second);
4525 db.names.pop_back();
4526 db.names.back().first.insert(0, ret1);
4529 db.names.back().first += '(';
4539 size_t k0 = db.names.size();
4540 t2 = parse_type(t, last, db);
4541 size_t k1 = db.names.size();
4551 tmp += db.names[k].move_full();
4554 db.names.pop_back();
4557 if (db.names.empty())
4560 db.names.back().first += ", ";
4563 db.names.back().first += tmp;
4569 if (db.names.empty())
4571 db.names.back().first += ')';
4573 db.names.back().first.append(" const");
4575 db.names.back().first.append(" volatile");
4577 db.names.back().first.append(" restrict");
4579 db.names.back().first.append(" &");
4581 db.names.back().first.append(" &&");
4582 db.names.back().first += ret2;
4601 parse_block_invoke(const char* first, const char* last, C& db)
4625 if (db.names.empty())
4627 db.names.back().first.insert(0, "invocation function for block in ");
4638 parse_dot_suffix(const char* first, const char* last, C& db)
4642 if (db.names.empty())
4644 db.names.back().first += " (" + typename C::String(first, last) + ")";
4658 demangle(const char* first, const char* last, C& db, int& status)
4671 const char* t = parse_encoding(first+2, last, db);
4673 t = parse_dot_suffix(t, last, db);
4679 const char* t = parse_encoding(first+4, last, db);
4682 const char* t1 = parse_block_invoke(t, last, db);
4697 const char* t = parse_type(first, last, db);
4701 if (status == success && db.names.empty())
4869 struct Db
4887 Db(arena<N>& ar) :
4909 Db db(a);
4910 db.cv = 0;
4911 db.ref = 0;
4912 db.encoding_depth = 0;
4913 db.parsed_ctor_dtor_cv = false;
4914 db.tag_templates = true;
4915 db.template_param.emplace_back(a);
4916 db.fix_forward_references = false;
4917 db.try_to_parse_template_args = true;
4920 demangle(mangled_name, mangled_name + len, db,
4922 if (internal_status == success && db.fix_forward_references &&
4923 !db.template_param.empty() && !db.template_param.front().empty())
4925 db.fix_forward_references = false;
4926 db.tag_templates = false;
4927 db.names.clear();
4928 db.subs.clear();
4929 demangle(mangled_name, mangled_name + len, db, internal_status);
4930 if (db.fix_forward_references)
4935 size_t sz = db
4953 db.names.back().first += db.names.back().second;
4954 std::memcpy(buf, db.names.back().first.data(), sz-1);