27 namespace debugging_internal {
44 {
"da",
"delete[]", 1},
92 {
nullptr,
nullptr, 0},
101 {
"a",
"signed char", 0},
102 {
"h",
"unsigned char", 0},
104 {
"t",
"unsigned short", 0},
106 {
"j",
"unsigned int", 0},
108 {
"m",
"unsigned long", 0},
109 {
"x",
"long long", 0},
110 {
"y",
"unsigned long long", 0},
111 {
"n",
"__int128", 0},
112 {
"o",
"unsigned __int128", 0},
115 {
"e",
"long double", 0},
116 {
"g",
"__float128", 0},
117 {
"z",
"ellipsis", 0},
118 {
nullptr,
nullptr, 0},
124 {
"Sa",
"allocator", 0},
125 {
"Sb",
"basic_string", 0},
129 {
"Si",
"istream", 0},
131 {
"So",
"ostream", 0},
133 {
"Sd",
"iostream", 0},
134 {
nullptr,
nullptr, 0},
143 signed int prev_name_length : 16;
144 signed int nest_level : 15;
145 unsigned int append : 1;
152 static_assert(
sizeof(
ParseState) == 4 *
sizeof(
int),
153 "unexpected size of ParseState");
173 class ComplexityGuard {
175 explicit ComplexityGuard(
State *state) :
state_(state) {
179 ~ComplexityGuard() { --
state_->recursion_depth; }
202 bool IsTooComplex()
const {
203 return state_->recursion_depth > kRecursionDepthLimit ||
216 while (*str !=
'\0') {
225 for (
int i = 0;
i <
n; ++
i) {
226 if (str[
i] ==
'\0') {
234 static bool StrPrefix(
const char *str,
const char *prefix) {
236 while (str[i] !=
'\0' && prefix[i] !=
'\0' && str[i] == prefix[i]) {
239 return prefix[
i] ==
'\0';
266 ComplexityGuard guard(state);
267 if (guard.IsTooComplex())
return false;
279 ComplexityGuard guard(state);
280 if (guard.IsTooComplex())
return false;
292 ComplexityGuard guard(state);
293 if (guard.IsTooComplex())
return false;
297 const char *p = char_class;
298 for (; *p !=
'\0'; ++p) {
310 if (digit !=
nullptr) {
324 if (parse_func(state)) {
325 while (parse_func(state)) {
337 while (parse_func(state)) {
363 static bool IsLower(
char c) {
return c >=
'a' && c <=
'z'; }
366 return (c >=
'a' && c <=
'z') || (c >=
'A' && c <=
'Z');
369 static bool IsDigit(
char c) {
return c >=
'0' && c <=
'9'; }
377 while (str[i] !=
'\0') {
379 if (str[i] !=
'.' || !
IsAlpha(str[i + 1])) {
386 if (str[i] !=
'.' || !
IsDigit(str[i + 1])) {
408 if (str[0] ==
'<' &&
EndsWith(state,
'<')) {
412 if (
IsAlpha(str[0]) || str[0] ==
'_') {
416 Append(state, str, length);
423 constexpr
size_t kMaxLength = 20;
424 char buf[kMaxLength];
431 char *p = &buf[kMaxLength];
433 *--p = (val % 10) +
'0';
435 }
while (p > buf && val != 0);
438 Append(state, p, kMaxLength - (p - buf));
505 static const char anon_prefix[] =
"_GLOBAL__N_";
506 return (length > static_cast<int>(
sizeof(anon_prefix) - 1) &&
587 ComplexityGuard guard(state);
588 if (guard.IsTooComplex())
return false;
596 ComplexityGuard guard(state);
597 if (guard.IsTooComplex())
return false;
618 ComplexityGuard guard(state);
619 if (guard.IsTooComplex())
return false;
648 ComplexityGuard guard(state);
649 if (guard.IsTooComplex())
return false;
674 ComplexityGuard guard(state);
675 if (guard.IsTooComplex())
return false;
700 ComplexityGuard guard(state);
701 if (guard.IsTooComplex())
return false;
702 bool has_something =
false;
709 has_something =
true;
729 ComplexityGuard guard(state);
730 if (guard.IsTooComplex())
return false;
738 ComplexityGuard guard(state);
739 if (guard.IsTooComplex())
return false;
755 ComplexityGuard guard(state);
756 if (guard.IsTooComplex())
return false;
771 ComplexityGuard guard(state);
772 if (guard.IsTooComplex())
return false;
780 which <= std::numeric_limits<int>::max() - 2 &&
794 which <= std::numeric_limits<int>::max() - 2 &&
810 ComplexityGuard guard(state);
811 if (guard.IsTooComplex())
return false;
812 bool negative =
false;
818 for (; *p !=
'\0'; ++p) {
820 number = number * 10 + (*p -
'0');
829 number = ~number + 1;
833 if (number_out !=
nullptr) {
835 *number_out = number;
845 ComplexityGuard guard(state);
846 if (guard.IsTooComplex())
return false;
848 for (; *p !=
'\0'; ++p) {
849 if (!
IsDigit(*p) && !(*p >=
'a' && *p <=
'f')) {
863 ComplexityGuard guard(state);
864 if (guard.IsTooComplex())
return false;
866 for (; *p !=
'\0'; ++p) {
867 if (!
IsDigit(*p) && !(*p >=
'A' && *p <=
'Z')) {
880 ComplexityGuard guard(state);
881 if (guard.IsTooComplex())
return false;
898 ComplexityGuard guard(state);
899 if (guard.IsTooComplex())
return false;
908 if (arity !=
nullptr) {
930 for (p = kOperatorList; p->
abbrev !=
nullptr; ++p) {
933 if (arity !=
nullptr) {
967 ComplexityGuard guard(state);
968 if (guard.IsTooComplex())
return false;
1029 ComplexityGuard guard(state);
1030 if (guard.IsTooComplex())
return false;
1049 ComplexityGuard guard(state);
1050 if (guard.IsTooComplex())
return false;
1056 ComplexityGuard guard(state);
1057 if (guard.IsTooComplex())
return false;
1073 ComplexityGuard guard(state);
1074 if (guard.IsTooComplex())
return false;
1099 ComplexityGuard guard(state);
1100 if (guard.IsTooComplex())
return false;
1131 ComplexityGuard guard(state);
1132 if (guard.IsTooComplex())
return false;
1208 ComplexityGuard guard(state);
1209 if (guard.IsTooComplex())
return false;
1210 int num_cv_qualifiers = 0;
1214 return num_cv_qualifiers > 0;
1220 ComplexityGuard guard(state);
1221 if (guard.IsTooComplex())
return false;
1223 for (p = kBuiltinTypeList; p->
abbrev !=
nullptr; ++p) {
1241 ComplexityGuard guard(state);
1242 if (guard.IsTooComplex())
return false;
1255 ComplexityGuard guard(state);
1256 if (guard.IsTooComplex())
return false;
1270 ComplexityGuard guard(state);
1271 if (guard.IsTooComplex())
return false;
1278 ComplexityGuard guard(state);
1279 if (guard.IsTooComplex())
return false;
1297 ComplexityGuard guard(state);
1298 if (guard.IsTooComplex())
return false;
1310 ComplexityGuard guard(state);
1311 if (guard.IsTooComplex())
return false;
1330 ComplexityGuard guard(state);
1331 if (guard.IsTooComplex())
return false;
1339 ComplexityGuard guard(state);
1340 if (guard.IsTooComplex())
return false;
1358 ComplexityGuard guard(state);
1359 if (guard.IsTooComplex())
return false;
1481 ComplexityGuard guard(state);
1482 if (guard.IsTooComplex())
return false;
1511 ComplexityGuard guard(state);
1512 if (guard.IsTooComplex())
return false;
1566 ComplexityGuard guard(state);
1567 if (guard.IsTooComplex())
return false;
1690 ComplexityGuard guard(state);
1691 if (guard.IsTooComplex())
return false;
1723 ComplexityGuard guard(state);
1724 if (guard.IsTooComplex())
return false;
1752 ComplexityGuard guard(state);
1753 if (guard.IsTooComplex())
return false;
1771 ComplexityGuard guard(state);
1772 if (guard.IsTooComplex())
return false;
1784 ComplexityGuard guard(state);
1785 if (guard.IsTooComplex())
return false;
1806 ComplexityGuard guard(state);
1807 if (guard.IsTooComplex())
return false;
1824 for (p = kSubstitutionList; p->
abbrev !=
nullptr; ++p) {
1826 (accept_std || p->
abbrev[1] !=
't')) {
1844 ComplexityGuard guard(state);
1845 if (guard.IsTooComplex())
return false;
1872 InitState(&state, mangled, out, out_size);
static bool ParseBuiltinType(State *state)
static bool ParseClassEnumType(State *state)
static bool ParseCharClass(State *state, const char *char_class)
static bool ParseFunctionType(State *state)
static bool ParseTemplateParam(State *state)
static bool ParseDigit(State *state, int *digit)
static void MaybeCancelLastSeparator(State *state)
static void MaybeAppendWithLength(State *state, const char *const str, const int length)
static bool ParseCVQualifiers(State *state)
static bool OneOrMore(ParseFunc parse_func, State *state)
static bool IsAlpha(char c)
static bool ParseNestedName(State *state)
static void InitState(State *state, const char *mangled, char *out, int out_size)
static bool ParseVOffset(State *state)
signed int prev_name_length
bool Demangle(const char *mangled, char *out, int out_size)
static size_t StrLen(const char *str)
static bool ParseOneCharToken(State *state, const char one_char_token)
static bool MaybeAppendDecimal(State *state, unsigned int val)
static bool ParseNVOffset(State *state)
static const char * RemainingInput(State *state)
static bool Overflowed(const State *state)
static const AbbrevPair kBuiltinTypeList[]
static bool ParseTwoCharToken(State *state, const char *two_char_token)
static bool EnterNestedName(State *state)
static const AbbrevPair kSubstitutionList[]
static bool IdentifierIsAnonymousNamespace(State *state, int length)
static bool ParseUnresolvedType(State *state)
static bool IsLower(char c)
static bool ParseExprPrimary(State *state)
static bool ParseIdentifier(State *state, int length)
static bool ParsePointerToMemberType(State *state)
static bool ParseSeqId(State *state)
static bool IsFunctionCloneSuffix(const char *str)
static bool ZeroOrMore(ParseFunc parse_func, State *state)
static bool ParseSubstitution(State *state, bool accept_std)
static bool ParseExprCastValue(State *state)
static bool ParseCtorDtorName(State *state)
static bool ParseUnscopedName(State *state)
static bool ParseUnresolvedName(State *state)
static void Append(State *state, const char *const str, const int length)
static bool ParseTemplateTemplateParam(State *state)
static bool ParseType(State *state)
static bool LeaveNestedName(State *state, int16_t prev_value)
static bool MaybeAppend(State *state, const char *const str)
static bool ParseTopLevelMangledName(State *state)
static bool ParseFloatNumber(State *state)
static const AbbrevPair kOperatorList[]
static bool ParseLocalName(State *state)
const char * mangled_begin
static bool ParseRefQualifier(State *state)
static bool IsDigit(char c)
static bool StrPrefix(const char *str, const char *prefix)
static void MaybeIncreaseNestLevel(State *state)
static bool ParseSourceName(State *state)
static bool ParseExpression(State *state)
static bool ParseTemplateArg(State *state)
static bool ParseLocalNameSuffix(State *state)
static bool ParseBaseUnresolvedName(State *state)
static bool ParseSimpleId(State *state)
static bool DisableAppend(State *state)
static bool AtLeastNumCharsRemaining(const char *str, int n)
static bool ParseSpecialName(State *state)
static bool ParseLocalSourceName(State *state)
static constexpr int kRecursionDepthLimit
static bool EndsWith(State *state, const char chr)
static bool ParsePrefix(State *state)
static bool ParseMangledName(State *state)
static bool ParseCallOffset(State *state)
static bool ParseDecltype(State *state)
static bool ParseBareFunctionType(State *state)
static bool ParseArrayType(State *state)
static constexpr int kParseStepsLimit
static bool ParseNumber(State *state, int *number_out)
static bool ParseUnnamedTypeName(State *state)
static bool ParseUnqualifiedName(State *state)
static bool Optional(bool)
static bool RestoreAppend(State *state, bool prev_value)
static bool ParseDiscriminator(State *state)
bool(* ParseFunc)(State *)
static bool ParseName(State *state)
static bool ParseEncoding(State *state)
static void MaybeAppendSeparator(State *state)
static bool ParseTemplateArgs(State *state)
static bool ParseOperatorName(State *state, int *arity)