Home | History | Annotate | Download | only in src

Lines Matching defs:first

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);
61 fprintf(stderr, "{%s#%s}\n", s.first.c_str(), s.second.c_str());
71 fprintf(stderr, "{%s#%s}", s.first.c_str(), s.second.c_str());
87 fprintf(stderr, "{%s#%s}", s.first.c_str(), s.second.c_str());
97 print_state(const char* msg, const char* first, const char* last, const C& db)
100 for (; first != last; ++first)
101 fprintf(stderr, "%c", *first);
109 parse_number(const char* first, const char* last)
111 if (first != last)
113 const char* t = first;
120 first = t+1;
124 first = t+1;
125 while (first != last && std::isdigit(*first))
126 ++first;
130 return first;
174 parse_floating_number(const char* first, const char* last, C& db)
177 if (static_cast<std::size_t>(last - first) > N)
179 last = first + N;
185 const char* t = first;
190 return first;
206 return first;
208 first = t+1;
211 return first;
218 parse_source_name(const char* first, const char* last, C& db)
220 if (first != last)
222 char c = *first;
223 if (isdigit(c) && first+1 != last)
225 const char* t = first+1;
231 return first;
240 first = t + n;
244 return first;
260 parse_substitution(const char* first, const char* last, C& db)
262 if (last - first >= 2)
264 if (*first == 'S')
266 switch (first[1])
270 first += 2;
274 first += 2;
278 first += 2;
282 first += 2;
286 first += 2;
290 first += 2;
297 first += 2;
301 if (std::isdigit(first[1]) || std::isupper(first[1]))
304 const char* t = first+1;
318 return first;
324 first = t+1;
331 return first;
368 parse_builtin_type(const char* first, const char* last, C& db)
370 if (first != last)
372 switch (*first)
376 ++first;
380 ++first;
384 ++first;
388 ++first;
392 ++first;
396 ++first;
400 ++first;
404 ++first;
408 ++first;
412 ++first;
416 ++first;
420 ++first;
424 ++first;
428 ++first;
432 ++first;
436 ++first;
440 ++first;
444 ++first;
448 ++first;
452 ++first;
456 ++first;
460 const char*t = parse_source_name(first+1, last, db);
461 if (t != first+1)
462 first = t;
466 if (first+1 != last)
468 switch (first[1])
472 first += 2;
476 first += 2;
480 first += 2;
484 first += 2;
488 first += 2;
492 first += 2;
496 first += 2;
500 first += 2;
504 first += 2;
511 return first;
517 parse_cv_qualifiers(const char* first, const char* last, unsigned& cv)
520 if (first != last)
522 if (*first == 'r')
525 ++first;
527 if (*first == 'V')
530 ++first;
532 if (*first == 'K')
535 ++first;
538 return first;
541 // <template-param> ::= T_ # first template parameter
546 parse_template_param(const char* first, const char* last, C& db)
548 if (last - first >= 2)
550 if (*first == 'T')
552 if (first[1] == '_')
555 return first;
560 first += 2;
565 first += 2;
569 else if (isdigit(first[1]))
571 const char* t = first+1;
579 return first;
585 first = t+1;
589 db.names.push_back(typename C::String(first, t+1));
590 first = t+1;
596 return first;
603 parse_const_cast_expr(const char* first, const char* last, C& db)
605 if (last - first >= 3 && first[0] == 'c' && first[1] == 'c')
607 const char* t = parse_type(first+2, last, db);
608 if (t != first+2)
614 return first;
618 first = t1;
622 return first;
629 parse_dynamic_cast_expr(const char* first, const char* last, C& db)
631 if (last - first >= 3 && first[0] == 'd' && first[1] == 'c')
633 const char* t = parse_type(first+2, last, db);
634 if (t != first+2)
640 return first;
644 first = t1;
648 return first;
655 parse_reinterpret_cast_expr(const char* first, const char* last, C& db)
657 if (last - first >= 3 && first[0] == 'r' && first[1] == 'c')
659 const char* t = parse_type(first+2, last, db);
660 if (t != first+2)
666 return first;
670 first = t1;
674 return first;
681 parse_static_cast_expr(const char* first, const char* last, C& db)
683 if (last - first >= 3 && first[0] == 's' && first[1] == 'c')
685 const char* t = parse_type(first+2, last, db);
686 if (t != first+2)
692 return first;
696 first = t1;
700 return first;
707 parse_pack_expansion(const char* first, const char* last, C& db)
709 if (last - first >= 3 && first[0] == 's' && first[1] == 'p')
711 const char* t = parse_expression(first+2, last, db);
712 if (t != first+2)
713 first = t;
715 return first;
722 parse_sizeof_type_expr(const char* first, const char* last, C& db)
724 if (last - first >= 3 && first[0] == 's' && first[1] == 't')
726 const char* t = parse_type(first+2, last, db);
727 if (t != first+2)
730 return first;
732 first = t;
735 return first;
742 parse_sizeof_expr_expr(const char* first, const char* last, C& db)
744 if (last - first >= 3 && first[0] == 's' && first[1] == 'z')
746 const char* t = parse_expression(first+2, last, db);
747 if (t != first+2)
750 return first;
752 first = t;
755 return first;
762 parse_sizeof_param_pack_expr(const char* first, const char* last, C& db)
764 if (last - first >= 3 && first[0] == 's' && first[1] == 'Z' && first[2] == 'T')
767 const char* t = parse_template_param(first+2, last, db);
769 if (t != first+2)
783 first = t;
786 return first;
789 // <function-param> ::= fp <top-level CV-qualifiers> _ # L == 0, first parameter
791 // ::= fL <L-1 non-negative number> p <top-level CV-qualifiers> _ # L > 0, first parameter
796 parse_function_param(const char* first, const char* last, C& db)
798 if (last - first >= 3 && *first == 'f')
800 if (first[1] == 'p')
803 const char* t = parse_cv_qualifiers(first+2, last, cv);
808 first = t1+1;
811 else if (first[1] == 'L')
814 const char* t0 = parse_number(first+2, last);
823 first = t1+1;
828 return first;
835 parse_sizeof_function_param_pack_expr(const char* first, const char* last, C& db)
837 if (last - first >= 3 && first[0] == 's' && first[1] == 'Z' && first[2] == 'f')
839 const char* t = parse_function_param(first+2, last, db);
840 if (t != first+2)
843 return first;
845 first = t;
848 return first;
856 parse_typeid_expr(const char* first, const char* last, C& db)
858 if (last - first >= 3 && first[0] == 't' && (first[1] == 'e' || first[1] == 'i'))
861 if (first[1] == 'e')
862 t = parse_expression(first+2, last, db);
864 t = parse_type(first+2, last, db);
865 if (t != first+2)
868 return first;
870 first = t;
873 return first;
880 parse_throw_expr(const char* first, const char* last, C& db)
882 if (last - first >= 3 && first[0] == 't' && first[1] == 'w')
884 const char* t = parse_expression(first+2, last, db);
885 if (t != first+2)
888 return first;
890 first = t;
893 return first;
900 parse_dot_star_expr(const char* first, const char* last, C& db)
902 if (last - first >= 3 && first[0] == 'd' && first[1] == 's')
904 const char* t = parse_expression(first+2, last, db);
905 if (t != first+2)
911 return first;
914 db.names.back().first += ".*" + expr;
915 first = t1;
919 return first;
926 parse_simple_id(const char* first, const char* last, C& db)
928 if (first != last)
930 const char* t = parse_source_name(first, last, db);
931 if (t != first)
937 return first;
940 db.names.back().first += std::move(args);
942 first = t1;
945 first = t;
947 return first;
956 parse_unresolved_type(const char* first, const char* last, C& db)
958 if (first != last)
960 const char* t = first;
961 switch (*first)
966 t = parse_template_param(first, last, db);
968 if (t != first && k1 == k0 + 1)
971 first = t;
981 t = parse_decltype(first, last, db);
982 if (t != first)
985 return first;
987 first = t;
991 t = parse_substitution(first, last, db);
992 if (t != first)
993 first = t;
996 if (last - first > 2 && first[1] == 't')
998 t = parse_unqualified_name(first+2, last, db);
999 if (t != first+2)
1002 return first;
1003 db.names.back().first.insert(0, "std::");
1005 first = t;
1012 return first;
1020 parse_destructor_name(const char* first, const char* last, C& db)
1022 if (first != last)
1024 const char* t = parse_unresolved_type(first, last, db);
1025 if (t == first)
1026 t = parse_simple_id(first, last, db);
1027 if (t != first)
1030 return first;
1031 db.names.back().first.insert(0, "~");
1032 first = t;
1035 return first;
1048 parse_base_unresolved_name(const char* first, const char* last, C& db)
1050 if (last - first >= 2)
1052 if ((first[0] == 'o' || first[0] == 'd') && first[1] == 'n')
1054 if (first[0] == 'o')
1056 const char* t = parse_operator_name(first+2, last, db);
1057 if (t != first+2)
1059 first = parse_template_args(t, last, db);
1060 if (first != t)
1063 return first;
1066 db.names.back().first += std::move(args);
1072 const char* t = parse_destructor_name(first+2, last, db);
1073 if (t != first+2)
1074 first = t;
1079 const char* t = parse_simple_id(first, last, db);
1080 if (t == first)
1082 t = parse_operator_name(first, last, db);
1083 if (t != first)
1085 first = parse_template_args(t, last, db);
1086 if (first
1089 return first;
1092 db.names.back().first += std::move(args);
1097 first = t;
1100 return first;
1107 parse_unresolved_qualifier_level(const char* first, const char* last, C& db)
1109 return parse_simple_id(first, last, db);
1124 parse_unresolved_name(const char* first, const char* last, C& db)
1126 if (last - first > 2)
1128 const char* t = first;
1141 return first;
1142 db.names.back().first.insert(0, "::");
1144 first = t2;
1153 return first;
1159 return first;
1162 db.names.back().first += std::move(args);
1167 return first;
1174 return first;
1177 db.names.back().first += "::" + std::move(s);
1186 return first;
1189 return first;
1192 db.names.back().first += "::" + std::move(s);
1193 first = t1;
1206 return first;
1209 db.names.back().first += std::move(args);
1217 return first;
1220 return first;
1223 db.names.back().first += "::" + std::move(s);
1224 first = t1;
1230 return first;
1235 return first;
1236 db.names.back().first.insert(0, "::");
1242 return first;
1245 db.names.back().first += "::" + std::move(s);
1254 return first;
1257 return first;
1260 db.names.back().first += "::" + std::move(s);
1261 first = t1;
1266 return first;
1273 parse_dot_expr(const char* first, const char* last, C& db)
1275 if (last - first >= 3 && first[0] == 'd' && first[1] == 't')
1277 const char* t = parse_expression(first+2, last, db);
1278 if (t != first+2)
1284 return first;
1287 db.names.back().first += "." + name;
1288 first = t1;
1292 return first;
1299 parse_call_expr(const char* first, const char* last, C& db)
1301 if (last - first >= 4 && first[0] == 'c' && first[1] == 'l')
1303 const char* t = parse_expression(first+2, last, db);
1304 if (t != first+2)
1307 return first;
1309 return first;
1310 db.names.back().first += db.names.back().second;
1312 db.names.back().first.append("(");
1318 return first;
1320 return first;
1326 return first;
1329 db.names.back().first.append(", ");
1332 db.names.back().first.append(tmp);
1338 return first;
1339 db.names.back().first.append(")");
1340 first = t;
1343 return first;
1354 parse_new_expr(const char* first, const char* last, C& db)
1356 if (last - first >= 4)
1358 const char* t = first;
1370 return first;
1377 return first;
1382 return first;
1388 return first;
1389 db.names.back().first.append(", ");
1390 db.names.back().first.append(tmp);
1399 return first;
1411 return first;
1415 return first;
1421 return first;
1422 db.names.back().first.append(", ");
1423 db.names.back().first.append(tmp);
1431 return first;
1436 return first;
1441 return first;
1448 return first;
1465 first = t+1;
1468 return first;
1476 parse_conversion_expr(const char* first, const char* last, C& db)
1478 if (last - first >= 3 && first[0] == 'c' && first[1] == 'v')
1482 const char* t = parse_type(first+2, last, db);
1484 if (t != first+2 && t != last)
1490 return first;
1497 return first;
1507 return first;
1511 return first;
1517 return first;
1518 db.names.back().first.append(", ");
1519 db.names.back().first.append(tmp);
1529 return first;
1533 first = t;
1536 return first;
1543 parse_arrow_expr(const char* first, const char* last, C& db)
1545 if (last - first >= 3 && first[0] == 'p' && first[1] == 't')
1547 const char* t = parse_expression(first+2, last, db);
1548 if (t != first+2)
1554 return first;
1557 db.names.back().first += "->";
1558 db.names.back().first += tmp;
1559 first = t1;
1563 return first;
1573 parse_function_type(const char* first, const char* last, C& db)
1575 if (first != last && *first == 'F')
1577 const char* t = first+1;
1584 return first;
1597 return first;
1625 return first;
1647 return first;
1648 db.names.back().first += " ";
1650 first = t;
1654 return first;
1661 parse_pointer_to_member_type(const char* first, const char* last, C& db)
1663 if (first != last && *first == 'M')
1665 const char* t = parse_type(first+1, last, db);
1666 if (t != first+1)
1672 return first;
1678 db.names.back().first = std::move(func.first) + "(" + class_type.move_full() + "::*";
1683 db.names.back().first = std::move(func.first) + " " + class_type.move_full() + "::*";
1686 first = t2;
1690 return first;
1698 parse_array_type(const char* first, const char* last, C& db)
1700 if (first != last && *first == 'A' && first+1 != last)
1702 if (first[1] == '_')
1704 const char* t = parse_type(first+2, last, db);
1705 if (t != first+2)
1708 return first;
1712 first = t;
1715 else if ('1' <= first[1] && first[1] <= '9')
1717 const char* t = parse_number(first+1, last);
1724 return first;
1727 db.names.back().second.insert(0, " [" + typename C::String(first+1, t) + "]");
1728 first = t2;
1734 const char* t = parse_expression(first+1, last, db);
1735 if (t != first+1 && t != last && *t == '_')
1741 return first;
1745 db.names.back().first = std::move(type.first);
1749 first = t2;
1754 return first;
1762 parse_decltype(const char* first, const char* last, C& db)
1764 if (last - first >= 4 && first[0] == 'D')
1766 switch (first[1])
1771 const char* t = parse_expression(first+2, last, db);
1772 if (t != first+2 && t != last && *t == 'E')
1775 return first;
1777 first = t+1;
1783 return first;
1795 parse_vector_type(const char* first, const char* last, C& db)
1797 if (last - first > 3 && first[0] == 'D' && first[1] == 'v')
1799 if ('1' <= first[2] && first[2] <= '9')
1801 const char* t = parse_number(first+2, last);
1803 return first;
1804 const char* num = first + 2;
1814 return first;
1815 db.names.back().first += " vector[" + typename C::String(num, sz) + "]";
1816 first = t1;
1823 first = t;
1830 const char* t1 = first+2;
1837 return first;
1849 return first;
1850 db.names.back().first += " vector[" + num + "]";
1851 first = t;
1856 return first;
1884 parse_type(const char* first, const char* last, C& db)
1886 if (first != last)
1888 switch (*first)
1895 const char* t = parse_cv_qualifiers(first, last, cv);
1896 if (t != first)
1932 db.names[k].first.append(" const");
1934 db.names[k].first.append(" volatile");
1936 db.names[k].first.append(" restrict");
1940 first = t1;
1947 const char* t = parse_builtin_type(first, last, db);
1948 if (t != first)
1950 first = t;
1954 switch (*first)
1957 t = parse_array_type(first, last, db);
1958 if (t != first)
1961 return first;
1962 first = t;
1967 t = parse_type(first+1, last, db);
1968 if (t != first+1)
1971 return first;
1972 db.names.back().first.append(" complex");
1973 first = t;
1978 t = parse_function_type(first, last, db);
1979 if (t != first)
1982 return first;
1983 first = t;
1988 t = parse_type(first+1, last, db);
1989 if (t != first+1)
1992 return first;
1993 db.names.back().first.append(" imaginary");
1994 first = t;
1999 t = parse_pointer_to_member_type(first, last, db);
2000 if (t != first)
2003 return first;
2004 first = t;
2011 t = parse_type(first+1, last, db);
2013 if (t != first
2020 db.names[k].first += " (";
2026 db.names[k].first += "(";
2029 db.names[k].first.append("&&");
2032 first = t;
2039 t = parse_type(first+1, last, db);
2041 if (t != first+1)
2048 db.names[k].first += " (";
2054 db.names[k].first += "(";
2057 if (first[1] != 'U' || db.names[k].first.substr(0, 12) != "objc_object<")
2059 db.names[k].first.append("*");
2063 db.names[k].first.replace(0, 11, "id");
2067 first = t;
2074 t = parse_type(first+1, last, db);
2076 if (t != first+1)
2083 db.names[k].first += " (";
2089 db.names[k].first += "(";
2092 db.names[k].first.append("&");
2095 first = t;
2102 t = parse_template_param(first, last, db);
2104 if (t != first)
2116 db.names.back().first += std::move(args);
2121 first = t;
2126 if (first+1 != last)
2128 t = parse_source_name(first+1, last, db);
2129 if (t != first+1)
2135 return first;
2138 if (db.names.back().first.substr(0, 9) != "objcproto")
2157 first = t2;
2163 if (first+1 != last && first[1] == 't')
2165 t = parse_name(first, last, db);
2166 if (t != first)
2169 return first;
2171 first = t;
2176 t = parse_substitution(first, last, db);
2177 if (t != first)
2179 first = t;
2182 t = parse_template_args(first, last, db);
2183 if (t != first)
2186 return first;
2189 db.names.back().first += template_args;
2192 first = t;
2198 if (first+1 != last)
2200 switch (first[1])
2205 t = parse_type(first+2, last, db);
2207 if (t != first+2)
2212 first = t;
2213 return first;
2219 t = parse_decltype(first, last, db);
2220 if (t != first)
2223 return first;
2225 first = t;
2226 return first;
2230 t = parse_vector_type(first, last, db);
2231 if (t != first)
2234 return first;
2236 first = t;
2237 return first;
2246 t = parse_builtin_type(first, last, db);
2247 if (t != first)
2249 first = t;
2253 t = parse_name(first, last, db);
2254 if (t != first)
2257 return first;
2259 first = t;
2269 return first;
2326 parse_operator_name(const char* first, const char* last, C& db)
2328 if (last - first >= 2)
2330 switch (first[0])
2333 switch (first[1])
2337 first += 2;
2342 first += 2;
2346 first += 2;
2350 first += 2;
2355 switch (first[1])
2359 first += 2;
2363 first += 2;
2367 first += 2;
2373 const char* t = parse_type(first+2, last, db);
2375 if (t != first+2)
2378 return first;
2379 db.names.back().first.insert(0, "operator ");
2381 first = t;
2388 switch (first[1])
2392 first += 2;
2396 first += 2;
2400 first += 2;
2404 first += 2;
2408 first += 2;
2413 switch (first[1])
2417 first += 2;
2421 first += 2;
2425 first += 2;
2430 switch (first[1])
2434 first += 2;
2438 first += 2;
2443 if (first[1] == 'x')
2446 first += 2;
2450 switch (first[1])
2454 first += 2;
2458 const char* t = parse_source_name(first+2, last, db);
2459 if (t != first+2)
2462 return first;
2463 db.names.back().first.insert(0, "operator\"\" ");
2464 first = t;
2470 first += 2;
2474 first += 2;
2478 first += 2;
2483 switch (first[1])
2487 first += 2;
2491 first += 2;
2495 first += 2;
2499 first += 2;
2503 first += 2;
2508 switch (first[1])
2512 first += 2;
2516 first += 2;
2520 first += 2;
2524 first += 2;
2528 first += 2;
2533 switch (first[1])
2537 first += 2;
2541 first += 2;
2545 first += 2;
2550 switch (first[1])
2554 first += 2;
2558 first += 2;
2562 first += 2;
2566 first += 2;
2570 first += 2;
2574 first += 2;
2579 if (first[1] == 'u')
2582 first += 2;
2586 switch (first[1])
2590 first += 2;
2594 first += 2;
2598 first += 2;
2602 first += 2;
2607 if (std::isdigit(first[1]))
2609 const char* t = parse_source_name(first+2, last, db);
2610 if (t != first+2)
2613 return first;
2614 db.names.back().first.insert(0, "operator ");
2615 first = t;
2621 return first;
2626 parse_integer_literal(const char* first, const char* last, const typename C::String& lit, C& db)
2628 const char* t = parse_number(first, last);
2629 if (t != first && t != last && *t == 'E')
2635 if (*first == 'n')
2637 db.names.back().first += '-';
2638 ++first;
2640 db.names.back().first.append(first, t);
2642 db.names.back().first += lit;
2643 first = t+1;
2645 return first;
2657 parse_expr_primary(const char* first, const char* last, C& db)
2659 if (last - first >= 4 && *first == 'L')
2661 switch (first[1])
2665 const char* t = parse_integer_literal(first+2, last, "wchar_t", db);
2666 if (t != first+2)
2667 first = t;
2671 if (first[3] == 'E')
2673 switch (first[2])
2677 first += 4;
2681 first += 4;
2688 const char* t = parse_integer_literal(first+2, last, "char", db);
2689 if (t != first+2)
2690 first = t;
2695 const char* t = parse_integer_literal(first+2, last, "signed char", db);
2696 if (t != first+2)
2697 first = t;
2702 const char* t = parse_integer_literal(first+2, last, "unsigned char", db);
2703 if (t != first+2)
2704 first = t;
2709 const char* t = parse_integer_literal(first+2, last, "short", db);
2710 if (t != first+2)
2711 first = t;
2716 const char* t = parse_integer_literal(first+2, last, "unsigned short", db);
2717 if (t != first+2)
2718 first = t;
2723 const char* t = parse_integer_literal(first+2, last, "", db);
2724 if (t != first+2)
2725 first = t;
2730 const char* t = parse_integer_literal(first+2, last, "u", db);
2731 if (t != first+2)
2732 first = t;
2737 const char* t = parse_integer_literal(first+2, last, "l", db);
2738 if (t != first+2)
2739 first = t;
2744 const char* t = parse_integer_literal(first+2, last, "ul", db);
2745 if (t != first+2)
2746 first = t;
2751 const char* t = parse_integer_literal(first+2, last, "ll", db);
2752 if (t != first+2)
2753 first = t;
2758 const char* t = parse_integer_literal(first+2, last, "ull", db);
2759 if (t != first+2)
2760 first = t;
2765 const char* t = parse_integer_literal(first+2, last, "__int128", db);
2766 if (t != first+2)
2767 first = t;
2772 const char* t = parse_integer_literal(first+2, last, "unsigned __int128", db);
2773 if (t != first+2)
2774 first = t;
2779 const char* t = parse_floating_number<float>(first+2, last, db);
2780 if (t != first+2)
2781 first = t;
2786 const char* t = parse_floating_number<double>(first+2, last, db);
2787 if (t != first+2)
2788 first = t;
2793 const char* t = parse_floating_number<long double>(first+2, last, db);
2794 if (t != first+2)
2795 first = t;
2799 if (first[2] == 'Z')
2801 const char* t = parse_encoding(first+3, last, db);
2802 if (t != first+3 && t != last && *t == 'E')
2803 first = t+1;
2813 const char* t = parse_type(first+1, last, db);
2814 if (t != first+1 && t != last)
2824 return first;
2826 first = n+1;
2832 first = t+1;
2839 return first;
2912 parse_ctor_dtor_name(const char* first, const char* last, C& db)
2914 if (last-first >= 2 && !db.names.empty())
2916 switch (first[0])
2919 switch (first[1])
2926 return first;
2927 first));
2928 first += 2;
2934 switch (first[1])
2941 return first;
2942 db.names.push_back("~" + base_name(db.names.back().first));
2943 first += 2;
2950 return first;
2962 parse_unnamed_type_name(const char* first, const char* last, C& db)
2964 if (last - first > 2 && first[0] == 'U')
2966 char type = first[1];
2972 const char* t0 = first+2;
2976 return first;
2983 db.names.back().first.append(t0, t1);
2986 db.names.back().first.push_back('\'');
2990 return first;
2992 first = t0 + 1;
2998 const char* t0 = first+2;
2999 if (first[2] == 'v')
3001 db.names.back().first += ')';
3010 return first;
3013 return first;
3016 db.names.back().first.append(tmp);
3024 return first;
3029 db.names.back().first.append(", ");
3030 db.names.back().first.append(tmp);
3034 db.names.back().first.append(")");
3039 return first;
3045 return first;
3052 db.names.back().first.insert(db.names.back().first.begin()+7, t0, t1);
3058 return first;
3060 first = t0 + 1;
3065 return first;
3075 parse_unqualified_name(const char* first, const char* last, C& db)
3077 if (first != last)
3080 switch (*first)
3084 t = parse_ctor_dtor_name(first, last, db);
3085 if (t != first)
3086 first = t;
3089 t = parse_unnamed_type_name(first, last, db);
3090 if (t != first)
3091 first = t;
3102 t = parse_source_name(first, last, db);
3103 if (t != first)
3104 first = t;
3107 t = parse_operator_name(first, last, db);
3108 if (t != first)
3109 first = t;
3113 return first;
3122 parse_unscoped_name(const char* first, const char* last, C& db)
3124 if (last - first >= 2)
3126 const char* t0 = first;
3128 if (first[0] == 'S' && first[1] == 't')
3141 return first;
3142 db.names.back().first.insert(0, "std::");
3144 first = t1;
3147 return first;
3154 parse_alignof_type(const char* first, const char* last, C& db)
3156 if (last - first >= 3 && first[0] == 'a' && first[1] == 't')
3158 const char* t = parse_type(first+2, last, db);
3159 if (t != first+2)
3162 return first;
3163 db.names.back().first = "alignof (" + db.names.back().move_full() + ")";
3164 first = t;
3167 return first;
3174 parse_alignof_expr(const char* first, const char* last, C& db)
3176 if (last - first >= 3 && first[0] == 'a' && first[1] == 'z')
3178 const char* t = parse_expression(first+2, last, db);
3179 if (t != first+2)
3182 return first;
3183 db.names.back().first = "alignof (" + db.names.back().move_full() + ")";
3184 first = t;
3187 return first;
3192 parse_noexcept_expression(const char* first, const char* last, C& db)
3194 const char* t1 = parse_expression(first, last, db);
3195 if (t1 != first)
3198 return first;
3199 db.names.back().first = "noexcept (" + db.names.back().move_full() + ")";
3200 first = t1;
3202 return first;
3207 parse_prefix_expression(const char* first, const char* last, const typename C::String& op, C& db)
3209 const char* t1 = parse_expression(first, last, db);
3210 if (t1 != first)
3213 return first;
3214 db.names.back().first = op + "(" + db.names.back().move_full() + ")";
3215 first = t1;
3217 return first;
3222 parse_binary_expression(const char* first, const char* last, const typename C::String& op, C& db)
3224 const char* t1 = parse_expression(first, last, db);
3225 if (t1 != first)
3231 return first;
3235 auto& nm = db.names.back().first;
3242 first = t2;
3247 return first;
3292 parse_expression(const char* first, const char* last, C& db)
3294 if (last - first >= 2)
3296 const char* t = first;
3298 if (last - first >= 4 && t[0] == 'g' && t[1] == 's')
3306 first = parse_expr_primary(first, last, db);
3309 first = parse_template_param(first, last, db);
3312 first = parse_function_param(first, last, db);
3318 t = parse_binary_expression(first+2, last, "&&", db);
3319 if (t != first+2)
3320 first = t;
3323 t = parse_prefix_expression(first+2, last, "&", db);
3324 if (t != first+2)
3325 first = t;
3328 t = parse_binary_expression(first+2, last, "&", db);
3329 if (t != first+2)
3330 first = t;
3333 t = parse_binary_expression(first+2, last, "&=", db);
3334 if (t != first+2)
3335 first = t;
3338 t = parse_binary_expression(first+2, last, "=", db);
3339 if (t != first+2)
3340 first = t;
3343 first = parse_alignof_type(first, last, db);
3346 first = parse_alignof_expr(first, last, db);
3354 first = parse_const_cast_expr(first, last, db);
3357 first = parse_call_expr(first, last, db);
3360 t = parse_binary_expression(first+2, last, ",", db);
3361 if (t != first+2)
3362 first = t;
3365 t = parse_prefix_expression(first+2, last, "~", db);
3366 if (t != first+2)
3367 first = t;
3370 first = parse_conversion_expr(first, last, db);
3383 return first;
3384 db.names.back().first = (parsed_gs ? typename C::String("::") : typename C::String()) +
3386 first = t1;
3391 first = parse_dynamic_cast_expr(first, last, db);
3394 t = parse_prefix_expression(first+2, last, "*", db);
3395 if (t != first+2)
3396 first = t;
3404 return first;
3405 db.names.back().first = (parsed_gs ? typename C::String("::") : typename C::String()) +
3407 first = t1;
3412 return parse_unresolved_name(first, last, db);
3414 first = parse_dot_star_expr(first, last, db);
3417 first = parse_dot_expr(first, last, db);
3420 t = parse_binary_expression(first+2, last, "/", db);
3421 if (t != first+2)
3422 first = t;
3425 t = parse_binary_expression(first+2, last, "/=", db);
3426 if (t != first+2)
3427 first = t;
3435 t = parse_binary_expression(first+2, last, "^", db);
3436 if (t != first+2)
3437 first = t;
3440 t = parse_binary_expression(first+2, last, "^=", db);
3441 if (t != first+2)
3442 first = t;
3445 t = parse_binary_expression(first+2, last, "==", db);
3446 if (t != first+2)
3447 first = t;
3455 t = parse_binary_expression(first+2, last, ">=", db);
3456 if (t != first+2)
3457 first = t;
3460 t = parse_binary_expression(first+2, last, ">", db);
3461 if (t != first+2)
3462 first = t;
3469 const char* t1 = parse_expression(first+2, last, db);
3470 if (t1 != first+2)
3476 return first;
3481 first = t2;
3492 t = parse_binary_expression(first+2, last, "<=", db);
3493 if (t != first+2)
3494 first = t;
3497 t = parse_binary_expression(first+2, last, "<<", db);
3498 if (t != first+2)
3499 first = t;
3502 t = parse_binary_expression(first+2, last, "<<=", db);
3503 if (t != first+2)
3504 first = t;
3507 t = parse_binary_expression(first+2, last, "<", db);
3508 if (t != first+2)
3509 first = t;
3517 t = parse_binary_expression(first+2, last, "-", db);
3518 if (t != first+2)
3519 first = t;
3522 t = parse_binary_expression(first+2, last, "-=", db);
3523 if (t != first+2)
3524 first = t;
3527 t = parse_binary_expression(first+2, last, "*", db);
3528 if (t != first+2)
3529 first = t;
3532 t = parse_binary_expression(first+2, last, "*=", db);
3533 if (t != first+2)
3534 first = t;
3537 if (first+2 != last && first[2] == '_')
3539 t = parse_prefix_expression(first+3, last, "--", db);
3540 if (t != first+3)
3541 first = t;
3545 const char* t1 = parse_expression(first+2, last, db);
3546 if (t1 != first+2)
3549 return first;
3551 first = t1;
3562 first = parse_new_expr(first, last, db);
3565 t = parse_binary_expression(first+2, last, "!=", db);
3566 if (t != first+2)
3567 first = t;
3570 t = parse_prefix_expression(first+2, last, "-", db);
3571 if (t != first+2)
3572 first = t;
3575 t = parse_prefix_expression(first+2, last, "!", db);
3576 if (t != first+2)
3577 first = t;
3580 t = parse_noexcept_expression(first+2, last, db);
3581 if (t != first+2)
3582 first = t;
3590 return parse_unresolved_name(first, last, db);
3592 t = parse_binary_expression(first+2, last, "||", db);
3593 if (t != first+2)
3594 first = t;
3597 t = parse_binary_expression(first+2, last, "|", db);
3598 if (t != first+2)
3599 first = t;
3602 t = parse_binary_expression(first+2, last, "|=", db);
3603 if (t != first+2)
3604 first = t;
3612 t = parse_binary_expression(first+2, last, "->*", db);
3613 if (t != first+2)
3614 first = t;
3617 t = parse_binary_expression(first+2, last, "+", db);
3618 if (t != first+2)
3619 first = t;
3622 t = parse_binary_expression(first+2, last, "+=", db);
3623 if (t != first+2)
3624 first = t;
3627 if (first+2 != last && first[2] == '_')
3629 t = parse_prefix_expression(first+3, last, "++", db);
3630 if (t != first+3)
3631 first = t;
3635 const char* t1 = parse_expression(first+2, last, db);
3636 if (t1 != first+2)
3639 return first;
3641 first = t1;
3646 t = parse_prefix_expression(first+2, last, "+", db);
3647 if (t != first+2)
3648 first = t;
3651 first = parse_arrow_expr(first, last, db);
3658 const char* t1 = parse_expression(first+2, last, db);
3659 if (t1 != first+2)
3668 return first;
3675 first = t3;
3692 first = parse_reinterpret_cast_expr(first, last, db);
3695 t = parse_binary_expression(first+2, last, "%", db);
3696 if (t != first+2)
3697 first = t;
3700 t = parse_binary_expression(first+2, last, "%=", db);
3701 if (t != first+2)
3702 first = t;
3705 t = parse_binary_expression(first+2, last, ">>", db);
3706 if (t != first+2)
3707 first = t;
3710 t = parse_binary_expression(first+2, last, ">>=", db);
3711 if (t != first+2)
3712 first = t;
3720 first = parse_static_cast_expr(first, last, db);
3723 first = parse_pack_expansion(first, last, db);
3726 return parse_unresolved_name(first, last, db);
3728 first = parse_sizeof_type_expr(first, last, db);
3731 first = parse_sizeof_expr_expr(first, last, db);
3739 first = parse_sizeof_param_pack_expr(first, last, db);
3742 first = parse_sizeof_function_param_pack_expr(first, last, db);
3754 first = parse_typeid_expr(first, last, db);
3758 first += 2;
3761 first = parse_throw_expr(first, last, db);
3774 return parse_unresolved_name(first, last, db);
3777 return first;
3788 parse_template_arg(const char* first, const char* last, C& db)
3790 if (first != last)
3793 switch (*first)
3796 t = parse_expression(first+1, last, db);
3797 if (t != first+1)
3800 first = t+1;
3804 t = first+1;
3806 return first;
3811 return first;
3814 first = t+1;
3818 if (first+1 != last && first[1] == 'Z')
3820 t = parse_encoding(first+2, last, db);
3821 if (t != first+2 && t != last && *t == 'E')
3822 first = t+1;
3825 first = parse_expr_primary(first, last, db);
3829 first = parse_type(first, last, db);
3833 return first;
3841 parse_template_args(const char* first, const char* last, C& db)
3843 if (last - first >= 2 && *first == 'I')
3847 const char* t = first+1;
3859 return first;
3876 first = t + 1;
3884 return first;
3905 parse_nested_name(const char* first, const char* last, C& db,
3908 first != last && *first == 'N')
3911 const char* t0 = parse_cv_qualifiers(first+1, last, cv);
3913 return first;
3929 db.names.back().first = "std";
3934 return first;
3952 if (!db.names.back().first.empty())
3954 db.names.back().first += "::" + name;
3958 db.names.back().first = name;
3963 return first;
3971 if (!db.names.back().first.empty())
3972 db.names.back().first += "::" + name;
3974 db.names.back().first = name;
3980 return first;
3990 if (!db.names.back().first.empty())
3991 db.names.back().first += "::" + name;
3993 db.names.back().first = name;
3999 return first;
4007 db.names.back().first += name;
4013 return first;
4017 return first;
4026 if (!db.names.back().first.empty())
4027 db.names.back().first += "::" + name;
4029 db.names.back().first = name;
4035 return first;
4038 first = t0 + 1;
4045 return first;
4053 parse_discriminator(const char* first, const char* last)
4056 if (first != last)
4058 if (*first == '_')
4060 const char* t1 = first+1;
4064 first = t1+1;
4070 first = t1 + 1;
4074 else if (std::isdigit(*first))
4076 const char* t1 = first+1;
4079 first = t1;
4082 return first;
4091 parse_local_name(const char* first, const char* last, C& db,
4094 if (first != last && *first == 'Z')
4096 const char* t = parse_encoding(first+1, last, db);
4097 if (t != first+1 && t != last && *t == 'E' && ++t != last)
4102 first = parse_discriminator(t+1, last);
4104 return first;
4105 db.names.back().first.append("::string literal");
4119 return first;
4122 db.names.back().first.append("::");
4123 db.names.back().first.append(name);
4124 first = t1;
4138 first = parse_discriminator(t1, last);
4140 return first;
4143 db.names.back().first.append("::");
4144 db.names.back().first.append(name);
4153 return first;
4166 parse_name(const char* first, const char* last, C& db,
4169 if (last - first >= 2)
4171 const char* t0 = first;
4182 first = t1;
4190 first = t1;
4201 return first;
4208 return first;
4211 db.names.back().first += tmp;
4212 first = t1;
4218 first = t1;
4230 return first;
4233 db.names.back().first += tmp;
4234 first = t1;
4244 return first;
4257 parse_call_offset(const char* first, const char* last)
4259 if (first != last)
4261 switch (*first)
4265 const char* t = parse_number(first + 1, last);
4266 if (t != first + 1 && t != last && *t == '_')
4267 first = t + 1;
4272 const char* t = parse_number(first + 1, last);
4273 if (t != first + 1 && t != last && *t == '_')
4277 first = t2 + 1;
4283 return first;
4292 // # first call-offset is 'this' adjustment
4298 // extension ::= TC <first type> <number> _ <second type> # construction vtable for second-in-first
4303 parse_special_name(const char* first, const char* last, C& db)
4305 if (last - first > 2)
4308 switch (*first)
4311 switch (first[1])
4315 t = parse_type(first+2, last, db);
4316 if (t != first+2)
4319 return first;
4320 db.names.back().first.insert(0, "vtable for ");
4321 first = t;
4326 t = parse_type(first+2, last, db);
4327 if (t != first+2)
4330 return first;
4331 db.names.back().first.insert(0, "VTT for ");
4332 first = t;
4337 t = parse_type(first+2, last, db);
4338 if (t != first+2)
4341 return first;
4342 db.names.back().first.insert(0, "typeinfo for ");
4343 first = t;
4348 t = parse_type(first+2, last, db);
4349 if (t != first+2)
4352 return first;
4353 db.names.back().first.insert(0, "typeinfo name for ");
4354 first = t;
4360 const char* t0 = parse_call_offset(first+2, last);
4361 if (t0 == first+2)
4370 return first;
4371 db.names.back().first.insert(0, "covariant return thunk to ");
4372 first = t;
4377 // extension ::= TC <firstfirst
4378 t = parse_type(first+2, last, db);
4379 if (t != first+2)
4388 return first;
4391 db.names.back().first = "construction vtable for " +
4394 first = t1;
4402 const char* t0 = parse_call_offset(first+1, last);
4403 if (t0 == first+1)
4409 return first;
4410 if (first[2] == 'v')
4412 db.names.back().first.insert(0, "virtual thunk to ");
4413 first = t;
4417 db.names.back().first.insert(0, "non-virtual thunk to ");
4418 first = t;
4426 switch (first[1])
4430 t = parse_name(first+2, last, db);
4431 if (t != first+2)
4434 return first;
4435 db.names.back().first.insert(0, "guard variable for ");
4436 first = t;
4441 t = parse_name(first+2, last, db);
4442 if (t != first+2)
4445 return first;
4446 db.names.back().first.insert(0, "reference temporary for ");
4447 first = t;
4454 return first;
4483 parse_encoding(const char* first, const char* last, C& db)
4485 if (first != last)
4492 switch (*first)
4496 first = parse_special_name(first, last, db);
4501 const char* t = parse_name(first, last, db,
4505 if (t != first)
4514 return first;
4515 const typename C::String& nm = db.names.back().first;
4517 return first;
4522 return first;
4524 return first;
4525 auto ret1 = std::move(db.names.back().first);
4530 db.names.back().first.insert(0, ret1);
4533 db.names.back().first += '(';
4562 return first;
4564 db.names.back().first += ", ";
4567 db.names.back().first += tmp;
4574 return first;
4575 db.names.back().first += ')';
4577 db.names.back().first.append(" const");
4579 db.names.back().first.append(" volatile");
4581 db.names.back().first.append(" restrict");
4583 db.names.back().first.append(" &");
4585 db.names.back().first.append(" &&");
4586 db.names.back().first += ret2;
4587 first = t;
4590 first = t;
4596 return first;
4605 parse_block_invoke(const char* first, const char* last, C& db)
4607 if (last - first >= 13)
4610 const char* t = first;
4614 return first;
4622 return first;
4630 return first;
4631 db.names.back().first.insert(0, "invocation function for block in ");
4632 first = t;
4634 return first;
4642 parse_dot_suffix(const char* first, const char* last, C& db)
4644 if (first != last && *first == '.')
4647 return first;
4648 db.names.back().first += " (" + typename C::String(first, last) + ")";
4649 first = last;
4651 return first;
4662 demangle(const char* first, const char* last, C& db, int& status)
4664 if (first >= last)
4669 if (*first == '_')
4671 if (last - first >= 4)
4673 if (first[1] == 'Z')
4675 const char* t = parse_encoding(first+2, last, db);
4676 if (t != first+2 && t != last && *t == '.')
4681 else if (first[1] == '_' && first[2] == '_' && first[3] == 'Z')
4683 const char* t = parse_encoding(first+4, last, db);
4684 if (t != first+4 && t != last)
4701 const char* t = parse_type(first, last, db);
4858 StrT first;
4862 string_pair(StrT f) : first(std::move(f)) {}
4864 : first(std::move(f)), second(std::move(s)) {}
4866 string_pair(const char (&s)[N]) : first(s, N-1) {}
4868 size_t size() const {return first.size() + second.size();}
4869 StrT full() const {return first + second;}
4870 StrT move_full() {return std::move(first) + std::move(second);}
4957 db.names.back().first += db.names.back().second;
4958 std::memcpy(buf, db.names.back().first.data(), sz-1);