Skip to content

Commit a6c3488

Browse files
committedAug 16, 2018
Factor Node creation out of the demangler. No functionality change
intended. llvm-svn: 339944
1 parent 496bb86 commit a6c3488

File tree

1 file changed

+99
-77
lines changed

1 file changed

+99
-77
lines changed
 

‎llvm/lib/Demangle/ItaniumDemangle.cpp

+99-77
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,23 @@ class PODSmallVector {
19421942
}
19431943
};
19441944

1945+
class DefaultAllocator {
1946+
BumpPointerAllocator Alloc;
1947+
1948+
public:
1949+
void reset() { Alloc.reset(); }
1950+
1951+
template<typename T, typename ...Args> T *makeNode(Args &&...args) {
1952+
return new (Alloc.allocate(sizeof(T)))
1953+
T(std::forward<Args>(args)...);
1954+
}
1955+
1956+
void *allocateNodeArray(size_t sz) {
1957+
return Alloc.allocate(sizeof(Node *) * sz);
1958+
}
1959+
};
1960+
1961+
template<typename Alloc = DefaultAllocator>
19451962
struct Db {
19461963
const char *First;
19471964
const char *Last;
@@ -1972,7 +1989,7 @@ struct Db {
19721989
bool PermitForwardTemplateReferences = false;
19731990
bool ParsingLambdaParams = false;
19741991

1975-
BumpPointerAllocator ASTAllocator;
1992+
Alloc ASTAllocator;
19761993

19771994
Db(const char *First_, const char *Last_) : First(First_), Last(Last_) {}
19781995

@@ -1989,13 +2006,12 @@ struct Db {
19892006
}
19902007

19912008
template <class T, class... Args> T *make(Args &&... args) {
1992-
return new (ASTAllocator.allocate(sizeof(T)))
1993-
T(std::forward<Args>(args)...);
2009+
return ASTAllocator.template makeNode<T>(std::forward<Args>(args)...);
19942010
}
19952011

19962012
template <class It> NodeArray makeNodeArray(It begin, It end) {
19972013
size_t sz = static_cast<size_t>(end - begin);
1998-
void *mem = ASTAllocator.allocate(sizeof(Node *) * sz);
2014+
void *mem = ASTAllocator.allocateNodeArray(sz);
19992015
Node **data = new (mem) Node *[sz];
20002016
std::copy(begin, end, data);
20012017
return NodeArray(data, sz);
@@ -2132,7 +2148,7 @@ const char* parse_discriminator(const char* first, const char* last);
21322148
//
21332149
// <unscoped-template-name> ::= <unscoped-name>
21342150
// ::= <substitution>
2135-
Node *Db::parseName(NameState *State) {
2151+
template<typename Alloc> Node *Db<Alloc>::parseName(NameState *State) {
21362152
consumeIf('L'); // extension
21372153

21382154
if (look() == 'N')
@@ -2173,7 +2189,7 @@ Node *Db::parseName(NameState *State) {
21732189
// <local-name> := Z <function encoding> E <entity name> [<discriminator>]
21742190
// := Z <function encoding> E s [<discriminator>]
21752191
// := Z <function encoding> Ed [ <parameter number> ] _ <entity name>
2176-
Node *Db::parseLocalName(NameState *State) {
2192+
template<typename Alloc> Node *Db<Alloc>::parseLocalName(NameState *State) {
21772193
if (!consumeIf('Z'))
21782194
return nullptr;
21792195
Node *Encoding = parseEncoding();
@@ -2205,7 +2221,7 @@ Node *Db::parseLocalName(NameState *State) {
22052221
// <unscoped-name> ::= <unqualified-name>
22062222
// ::= St <unqualified-name> # ::std::
22072223
// extension ::= StL<unqualified-name>
2208-
Node *Db::parseUnscopedName(NameState *State) {
2224+
template<typename Alloc> Node *Db<Alloc>::parseUnscopedName(NameState *State) {
22092225
if (consumeIf("StL") || consumeIf("St")) {
22102226
Node *R = parseUnqualifiedName(State);
22112227
if (R == nullptr)
@@ -2220,27 +2236,28 @@ Node *Db::parseUnscopedName(NameState *State) {
22202236
// ::= <source-name>
22212237
// ::= <unnamed-type-name>
22222238
// ::= DC <source-name>+ E # structured binding declaration
2223-
Node *Db::parseUnqualifiedName(NameState *State) {
2224-
// <ctor-dtor-name>s are special-cased in parseNestedName().
2225-
Node *Result;
2226-
if (look() == 'U')
2227-
Result = parseUnnamedTypeName(State);
2228-
else if (look() >= '1' && look() <= '9')
2229-
Result = parseSourceName(State);
2230-
else if (consumeIf("DC")) {
2231-
size_t BindingsBegin = Names.size();
2232-
do {
2233-
Node *Binding = parseSourceName(State);
2234-
if (Binding == nullptr)
2235-
return nullptr;
2236-
Names.push_back(Binding);
2237-
} while (!consumeIf('E'));
2238-
Result = make<StructuredBindingName>(popTrailingNodeArray(BindingsBegin));
2239-
} else
2240-
Result = parseOperatorName(State);
2241-
if (Result != nullptr)
2242-
Result = parseAbiTags(Result);
2243-
return Result;
2239+
template<typename Alloc>
2240+
Node *Db<Alloc>::parseUnqualifiedName(NameState *State) {
2241+
// <ctor-dtor-name>s are special-cased in parseNestedName().
2242+
Node *Result;
2243+
if (look() == 'U')
2244+
Result = parseUnnamedTypeName(State);
2245+
else if (look() >= '1' && look() <= '9')
2246+
Result = parseSourceName(State);
2247+
else if (consumeIf("DC")) {
2248+
size_t BindingsBegin = Names.size();
2249+
do {
2250+
Node *Binding = parseSourceName(State);
2251+
if (Binding == nullptr)
2252+
return nullptr;
2253+
Names.push_back(Binding);
2254+
} while (!consumeIf('E'));
2255+
Result = make<StructuredBindingName>(popTrailingNodeArray(BindingsBegin));
2256+
} else
2257+
Result = parseOperatorName(State);
2258+
if (Result != nullptr)
2259+
Result = parseAbiTags(Result);
2260+
return Result;
22442261
}
22452262

22462263
// <unnamed-type-name> ::= Ut [<nonnegative number>] _
@@ -2249,7 +2266,7 @@ Node *Db::parseUnqualifiedName(NameState *State) {
22492266
// <closure-type-name> ::= Ul <lambda-sig> E [ <nonnegative number> ] _
22502267
//
22512268
// <lambda-sig> ::= <parameter type>+ # Parameter types or "v" if the lambda has no parameters
2252-
Node *Db::parseUnnamedTypeName(NameState *) {
2269+
template<typename Alloc> Node *Db<Alloc>::parseUnnamedTypeName(NameState *) {
22532270
if (consumeIf("Ut")) {
22542271
StringView Count = parseNumber();
22552272
if (!consumeIf('_'))
@@ -2278,7 +2295,7 @@ Node *Db::parseUnnamedTypeName(NameState *) {
22782295
}
22792296

22802297
// <source-name> ::= <positive length number> <identifier>
2281-
Node *Db::parseSourceName(NameState *) {
2298+
template<typename Alloc> Node *Db<Alloc>::parseSourceName(NameState *) {
22822299
size_t Length = 0;
22832300
if (parsePositiveInteger(&Length))
22842301
return nullptr;
@@ -2342,7 +2359,7 @@ Node *Db::parseSourceName(NameState *) {
23422359
// ::= rS # >>=
23432360
// ::= ss # <=> C++2a
23442361
// ::= v <digit> <source-name> # vendor extended operator
2345-
Node *Db::parseOperatorName(NameState *State) {
2362+
template<typename Alloc> Node *Db<Alloc>::parseOperatorName(NameState *State) {
23462363
switch (look()) {
23472364
case 'a':
23482365
switch (look(1)) {
@@ -2585,7 +2602,8 @@ Node *Db::parseOperatorName(NameState *State) {
25852602
// ::= D1 # complete object destructor
25862603
// ::= D2 # base object destructor
25872604
// extension ::= D5 # ?
2588-
Node *Db::parseCtorDtorName(Node *&SoFar, NameState *State) {
2605+
template<typename Alloc>
2606+
Node *Db<Alloc>::parseCtorDtorName(Node *&SoFar, NameState *State) {
25892607
if (SoFar->K == Node::KSpecialSubstitution) {
25902608
auto SSK = static_cast<SpecialSubstitution *>(SoFar)->SSK;
25912609
switch (SSK) {
@@ -2639,7 +2657,7 @@ Node *Db::parseCtorDtorName(Node *&SoFar, NameState *State) {
26392657
// <template-prefix> ::= <prefix> <template unqualified-name>
26402658
// ::= <template-param>
26412659
// ::= <substitution>
2642-
Node *Db::parseNestedName(NameState *State) {
2660+
template<typename Alloc> Node *Db<Alloc>::parseNestedName(NameState *State) {
26432661
if (!consumeIf('N'))
26442662
return nullptr;
26452663

@@ -2746,7 +2764,7 @@ Node *Db::parseNestedName(NameState *State) {
27462764
}
27472765

27482766
// <simple-id> ::= <source-name> [ <template-args> ]
2749-
Node *Db::parseSimpleId() {
2767+
template<typename Alloc> Node *Db<Alloc>::parseSimpleId() {
27502768
Node *SN = parseSourceName(/*NameState=*/nullptr);
27512769
if (SN == nullptr)
27522770
return nullptr;
@@ -2761,7 +2779,7 @@ Node *Db::parseSimpleId() {
27612779

27622780
// <destructor-name> ::= <unresolved-type> # e.g., ~T or ~decltype(f())
27632781
// ::= <simple-id> # e.g., ~A<2*N>
2764-
Node *Db::parseDestructorName() {
2782+
template<typename Alloc> Node *Db<Alloc>::parseDestructorName() {
27652783
Node *Result;
27662784
if (std::isdigit(look()))
27672785
Result = parseSimpleId();
@@ -2775,7 +2793,7 @@ Node *Db::parseDestructorName() {
27752793
// <unresolved-type> ::= <template-param>
27762794
// ::= <decltype>
27772795
// ::= <substitution>
2778-
Node *Db::parseUnresolvedType() {
2796+
template<typename Alloc> Node *Db<Alloc>::parseUnresolvedType() {
27792797
if (look() == 'T') {
27802798
Node *TP = parseTemplateParam();
27812799
if (TP == nullptr)
@@ -2800,7 +2818,7 @@ Node *Db::parseUnresolvedType() {
28002818
// ::= on <operator-name> <template-args> # unresolved operator template-id
28012819
// ::= dn <destructor-name> # destructor or pseudo-destructor;
28022820
// # e.g. ~X or ~X<N-1>
2803-
Node *Db::parseBaseUnresolvedName() {
2821+
template<typename Alloc> Node *Db<Alloc>::parseBaseUnresolvedName() {
28042822
if (std::isdigit(look()))
28052823
return parseSimpleId();
28062824

@@ -2832,7 +2850,7 @@ Node *Db::parseBaseUnresolvedName() {
28322850
// (ignored) ::= srN <unresolved-type> <unresolved-qualifier-level>+ E <base-unresolved-name>
28332851
//
28342852
// <unresolved-qualifier-level> ::= <simple-id>
2835-
Node *Db::parseUnresolvedName() {
2853+
template<typename Alloc> Node *Db<Alloc>::parseUnresolvedName() {
28362854
Node *SoFar = nullptr;
28372855

28382856
// srN <unresolved-type> [<template-args>] <unresolved-qualifier-level>* E <base-unresolved-name>
@@ -2913,7 +2931,7 @@ Node *Db::parseUnresolvedName() {
29132931

29142932
// <abi-tags> ::= <abi-tag> [<abi-tags>]
29152933
// <abi-tag> ::= B <source-name>
2916-
Node *Db::parseAbiTags(Node *N) {
2934+
template<typename Alloc> Node *Db<Alloc>::parseAbiTags(Node *N) {
29172935
while (consumeIf('B')) {
29182936
StringView SN = parseBareSourceName();
29192937
if (SN.empty())
@@ -2924,7 +2942,8 @@ Node *Db::parseAbiTags(Node *N) {
29242942
}
29252943

29262944
// <number> ::= [n] <non-negative decimal integer>
2927-
StringView Db::parseNumber(bool AllowNegative) {
2945+
template<typename Alloc>
2946+
StringView Db<Alloc>::parseNumber(bool AllowNegative) {
29282947
const char *Tmp = First;
29292948
if (AllowNegative)
29302949
consumeIf('n');
@@ -2936,7 +2955,7 @@ StringView Db::parseNumber(bool AllowNegative) {
29362955
}
29372956

29382957
// <positive length number> ::= [0-9]*
2939-
bool Db::parsePositiveInteger(size_t *Out) {
2958+
template<typename Alloc> bool Db<Alloc>::parsePositiveInteger(size_t *Out) {
29402959
*Out = 0;
29412960
if (look() < '0' || look() > '9')
29422961
return true;
@@ -2947,7 +2966,7 @@ bool Db::parsePositiveInteger(size_t *Out) {
29472966
return false;
29482967
}
29492968

2950-
StringView Db::parseBareSourceName() {
2969+
template<typename Alloc> StringView Db<Alloc>::parseBareSourceName() {
29512970
size_t Int = 0;
29522971
if (parsePositiveInteger(&Int) || numLeft() < Int)
29532972
return StringView();
@@ -2964,7 +2983,7 @@ StringView Db::parseBareSourceName() {
29642983
//
29652984
// <ref-qualifier> ::= R # & ref-qualifier
29662985
// <ref-qualifier> ::= O # && ref-qualifier
2967-
Node *Db::parseFunctionType() {
2986+
template<typename Alloc> Node *Db<Alloc>::parseFunctionType() {
29682987
Qualifiers CVQuals = parseCVQualifiers();
29692988

29702989
Node *ExceptionSpec = nullptr;
@@ -3027,7 +3046,7 @@ Node *Db::parseFunctionType() {
30273046
// ::= Dv [<dimension expression>] _ <element type>
30283047
// <extended element type> ::= <element type>
30293048
// ::= p # AltiVec vector pixel
3030-
Node *Db::parseVectorType() {
3049+
template<typename Alloc> Node *Db<Alloc>::parseVectorType() {
30313050
if (!consumeIf("Dv"))
30323051
return nullptr;
30333052
if (look() >= '1' && look() <= '9') {
@@ -3061,7 +3080,7 @@ Node *Db::parseVectorType() {
30613080

30623081
// <decltype> ::= Dt <expression> E # decltype of an id-expression or class member access (C++0x)
30633082
// ::= DT <expression> E # decltype of an expression (C++0x)
3064-
Node *Db::parseDecltype() {
3083+
template<typename Alloc> Node *Db<Alloc>::parseDecltype() {
30653084
if (!consumeIf('D'))
30663085
return nullptr;
30673086
if (!consumeIf('t') && !consumeIf('T'))
@@ -3076,7 +3095,7 @@ Node *Db::parseDecltype() {
30763095

30773096
// <array-type> ::= A <positive dimension number> _ <element type>
30783097
// ::= A [<dimension expression>] _ <element type>
3079-
Node *Db::parseArrayType() {
3098+
template<typename Alloc> Node *Db<Alloc>::parseArrayType() {
30803099
if (!consumeIf('A'))
30813100
return nullptr;
30823101

@@ -3109,7 +3128,7 @@ Node *Db::parseArrayType() {
31093128
}
31103129

31113130
// <pointer-to-member-type> ::= M <class type> <member type>
3112-
Node *Db::parsePointerToMemberType() {
3131+
template<typename Alloc> Node *Db<Alloc>::parsePointerToMemberType() {
31133132
if (!consumeIf('M'))
31143133
return nullptr;
31153134
Node *ClassType = parseType();
@@ -3125,7 +3144,7 @@ Node *Db::parsePointerToMemberType() {
31253144
// ::= Ts <name> # dependent elaborated type specifier using 'struct' or 'class'
31263145
// ::= Tu <name> # dependent elaborated type specifier using 'union'
31273146
// ::= Te <name> # dependent elaborated type specifier using 'enum'
3128-
Node *Db::parseClassEnumType() {
3147+
template<typename Alloc> Node *Db<Alloc>::parseClassEnumType() {
31293148
StringView ElabSpef;
31303149
if (consumeIf("Ts"))
31313150
ElabSpef = "struct";
@@ -3147,7 +3166,7 @@ Node *Db::parseClassEnumType() {
31473166
// <qualified-type> ::= <qualifiers> <type>
31483167
// <qualifiers> ::= <extended-qualifier>* <CV-qualifiers>
31493168
// <extended-qualifier> ::= U <source-name> [<template-args>] # vendor extended type qualifier
3150-
Node *Db::parseQualifiedType() {
3169+
template<typename Alloc> Node *Db<Alloc>::parseQualifiedType() {
31513170
if (consumeIf('U')) {
31523171
StringView Qual = parseBareSourceName();
31533172
if (Qual.empty())
@@ -3207,7 +3226,7 @@ Node *Db::parseQualifiedType() {
32073226
//
32083227
// <objc-name> ::= <k0 number> objcproto <k1 number> <identifier> # k0 = 9 + <number of digits in k1> + k1
32093228
// <objc-type> ::= <source-name> # PU<11+>objcproto 11objc_object<source-name> 11objc_object -> id<source-name>
3210-
Node *Db::parseType() {
3229+
template<typename Alloc> Node *Db<Alloc>::parseType() {
32113230
Node *Result = nullptr;
32123231

32133232
if (TypeCallback != nullptr)
@@ -3534,14 +3553,14 @@ Node *Db::parseType() {
35343553
return Result;
35353554
}
35363555

3537-
Node *Db::parsePrefixExpr(StringView Kind) {
3556+
template<typename Alloc> Node *Db<Alloc>::parsePrefixExpr(StringView Kind) {
35383557
Node *E = parseExpr();
35393558
if (E == nullptr)
35403559
return nullptr;
35413560
return make<PrefixExpr>(Kind, E);
35423561
}
35433562

3544-
Node *Db::parseBinaryExpr(StringView Kind) {
3563+
template<typename Alloc> Node *Db<Alloc>::parseBinaryExpr(StringView Kind) {
35453564
Node *LHS = parseExpr();
35463565
if (LHS == nullptr)
35473566
return nullptr;
@@ -3551,15 +3570,15 @@ Node *Db::parseBinaryExpr(StringView Kind) {
35513570
return make<BinaryExpr>(LHS, Kind, RHS);
35523571
}
35533572

3554-
Node *Db::parseIntegerLiteral(StringView Lit) {
3573+
template<typename Alloc> Node *Db<Alloc>::parseIntegerLiteral(StringView Lit) {
35553574
StringView Tmp = parseNumber(true);
35563575
if (!Tmp.empty() && consumeIf('E'))
35573576
return make<IntegerExpr>(Lit, Tmp);
35583577
return nullptr;
35593578
}
35603579

35613580
// <CV-Qualifiers> ::= [r] [V] [K]
3562-
Qualifiers Db::parseCVQualifiers() {
3581+
template<typename Alloc> Qualifiers Db<Alloc>::parseCVQualifiers() {
35633582
Qualifiers CVR = QualNone;
35643583
if (consumeIf('r'))
35653584
addQualifiers(CVR, QualRestrict);
@@ -3574,7 +3593,7 @@ Qualifiers Db::parseCVQualifiers() {
35743593
// ::= fp <top-level CV-Qualifiers> <parameter-2 non-negative number> _ # L == 0, second and later parameters
35753594
// ::= fL <L-1 non-negative number> p <top-level CV-Qualifiers> _ # L > 0, first parameter
35763595
// ::= fL <L-1 non-negative number> p <top-level CV-Qualifiers> <parameter-2 non-negative number> _ # L > 0, second and later parameters
3577-
Node *Db::parseFunctionParam() {
3596+
template<typename Alloc> Node *Db<Alloc>::parseFunctionParam() {
35783597
if (consumeIf("fp")) {
35793598
parseCVQualifiers();
35803599
StringView Num = parseNumber();
@@ -3601,7 +3620,7 @@ Node *Db::parseFunctionParam() {
36013620
// [gs] na <expression>* _ <type> E # new[] (expr-list) type
36023621
// [gs] na <expression>* _ <type> <initializer> # new[] (expr-list) type (init)
36033622
// <initializer> ::= pi <expression>* E # parenthesized initialization
3604-
Node *Db::parseNewExpr() {
3623+
template<typename Alloc> Node *Db<Alloc>::parseNewExpr() {
36053624
bool Global = consumeIf("gs");
36063625
bool IsArray = look(1) == 'a';
36073626
if (!consumeIf("nw") && !consumeIf("na"))
@@ -3634,7 +3653,7 @@ Node *Db::parseNewExpr() {
36343653

36353654
// cv <type> <expression> # conversion with one argument
36363655
// cv <type> _ <expression>* E # conversion with a different number of arguments
3637-
Node *Db::parseConversionExpr() {
3656+
template<typename Alloc> Node *Db<Alloc>::parseConversionExpr() {
36383657
if (!consumeIf("cv"))
36393658
return nullptr;
36403659
Node *Ty;
@@ -3670,7 +3689,7 @@ Node *Db::parseConversionExpr() {
36703689
// ::= L <nullptr type> E # nullptr literal (i.e., "LDnE")
36713690
// FIXME: ::= L <type> <real-part float> _ <imag-part float> E # complex floating point literal (C 2000)
36723691
// ::= L <mangled-name> E # external name
3673-
Node *Db::parseExprPrimary() {
3692+
template<typename Alloc> Node *Db<Alloc>::parseExprPrimary() {
36743693
if (!consumeIf('L'))
36753694
return nullptr;
36763695
switch (look()) {
@@ -3764,7 +3783,7 @@ Node *Db::parseExprPrimary() {
37643783
// ::= di <field source-name> <braced-expression> # .name = expr
37653784
// ::= dx <index expression> <braced-expression> # [expr] = expr
37663785
// ::= dX <range begin expression> <range end expression> <braced-expression>
3767-
Node *Db::parseBracedExpr() {
3786+
template<typename Alloc> Node *Db<Alloc>::parseBracedExpr() {
37683787
if (look() == 'd') {
37693788
switch (look(1)) {
37703789
case 'i': {
@@ -3810,7 +3829,7 @@ Node *Db::parseBracedExpr() {
38103829
// ::= fR <binary-operator-name> <expression> <expression>
38113830
// ::= fl <binary-operator-name> <expression>
38123831
// ::= fr <binary-operator-name> <expression>
3813-
Node *Db::parseFoldExpr() {
3832+
template<typename Alloc> Node *Db<Alloc>::parseFoldExpr() {
38143833
if (!consumeIf('f'))
38153834
return nullptr;
38163835

@@ -3919,7 +3938,7 @@ Node *Db::parseFoldExpr() {
39193938
// ::= fl <binary-operator-name> <expression>
39203939
// ::= fr <binary-operator-name> <expression>
39213940
// ::= <expr-primary>
3922-
Node *Db::parseExpr() {
3941+
template<typename Alloc> Node *Db<Alloc>::parseExpr() {
39233942
bool Global = consumeIf("gs");
39243943
if (numLeft() < 2)
39253944
return nullptr;
@@ -4394,7 +4413,7 @@ Node *Db::parseExpr() {
43944413
//
43954414
// <v-offset> ::= <offset number> _ <virtual offset number>
43964415
// # virtual base override, with vcall offset
4397-
bool Db::parseCallOffset() {
4416+
template<typename Alloc> bool Db<Alloc>::parseCallOffset() {
43984417
// Just scan through the call offset, we never add this information into the
43994418
// output.
44004419
if (consumeIf('h'))
@@ -4423,7 +4442,7 @@ bool Db::parseCallOffset() {
44234442
// ::= GR <object name> <seq-id> _ # Subsequent temporaries
44244443
// extension ::= TC <first type> <number> _ <second type> # construction vtable for second-in-first
44254444
// extension ::= GR <object name> # reference temporary for object
4426-
Node *Db::parseSpecialName() {
4445+
template<typename Alloc> Node *Db<Alloc>::parseSpecialName() {
44274446
switch (look()) {
44284447
case 'T':
44294448
switch (look(1)) {
@@ -4546,7 +4565,7 @@ Node *Db::parseSpecialName() {
45464565
// <encoding> ::= <function name> <bare-function-type>
45474566
// ::= <data name>
45484567
// ::= <special-name>
4549-
Node *Db::parseEncoding() {
4568+
template<typename Alloc> Node *Db<Alloc>::parseEncoding() {
45504569
if (look() == 'G' || look() == 'T')
45514570
return parseSpecialName();
45524571

@@ -4646,7 +4665,9 @@ struct FloatData<long double>
46464665

46474666
constexpr const char *FloatData<long double>::spec;
46484667

4649-
template <class Float> Node *Db::parseFloatingLiteral() {
4668+
template<typename Alloc>
4669+
template<class Float>
4670+
Node *Db<Alloc>::parseFloatingLiteral() {
46504671
const size_t N = FloatData<Float>::mangled_size;
46514672
if (numLeft() <= N)
46524673
return nullptr;
@@ -4661,7 +4682,7 @@ template <class Float> Node *Db::parseFloatingLiteral() {
46614682
}
46624683

46634684
// <seq-id> ::= <0-9A-Z>+
4664-
bool Db::parseSeqId(size_t *Out) {
4685+
template<typename Alloc> bool Db<Alloc>::parseSeqId(size_t *Out) {
46654686
if (!(look() >= '0' && look() <= '9') &&
46664687
!(look() >= 'A' && look() <= 'Z'))
46674688
return true;
@@ -4692,7 +4713,7 @@ bool Db::parseSeqId(size_t *Out) {
46924713
// <substitution> ::= Si # ::std::basic_istream<char, std::char_traits<char> >
46934714
// <substitution> ::= So # ::std::basic_ostream<char, std::char_traits<char> >
46944715
// <substitution> ::= Sd # ::std::basic_iostream<char, std::char_traits<char> >
4695-
Node *Db::parseSubstitution() {
4716+
template<typename Alloc> Node *Db<Alloc>::parseSubstitution() {
46964717
if (!consumeIf('S'))
46974718
return nullptr;
46984719

@@ -4756,7 +4777,7 @@ Node *Db::parseSubstitution() {
47564777

47574778
// <template-param> ::= T_ # first template parameter
47584779
// ::= T <parameter-2 non-negative number> _
4759-
Node *Db::parseTemplateParam() {
4780+
template<typename Alloc> Node *Db<Alloc>::parseTemplateParam() {
47604781
if (!consumeIf('T'))
47614782
return nullptr;
47624783

@@ -4792,7 +4813,7 @@ Node *Db::parseTemplateParam() {
47924813
// ::= <expr-primary> # simple expressions
47934814
// ::= J <template-arg>* E # argument pack
47944815
// ::= LZ <encoding> E # extension
4795-
Node *Db::parseTemplateArg() {
4816+
template<typename Alloc> Node *Db<Alloc>::parseTemplateArg() {
47964817
switch (look()) {
47974818
case 'X': {
47984819
++First;
@@ -4832,7 +4853,8 @@ Node *Db::parseTemplateArg() {
48324853

48334854
// <template-args> ::= I <template-arg>* E
48344855
// extension, the abi says <template-arg>+
4835-
Node *Db::parseTemplateArgs(bool TagTemplates) {
4856+
template <typename Alloc>
4857+
Node *Db<Alloc>::parseTemplateArgs(bool TagTemplates) {
48364858
if (!consumeIf('I'))
48374859
return nullptr;
48384860

@@ -4909,7 +4931,7 @@ parse_discriminator(const char* first, const char* last)
49094931
// extension ::= ___Z <encoding> _block_invoke
49104932
// extension ::= ___Z <encoding> _block_invoke<decimal-digit>+
49114933
// extension ::= ___Z <encoding> _block_invoke_<decimal-digit>+
4912-
Node *Db::parse() {
4934+
template<typename Alloc> Node *Db<Alloc>::parse() {
49134935
if (consumeIf("_Z")) {
49144936
Node *Encoding = parseEncoding();
49154937
if (Encoding == nullptr)
@@ -4969,7 +4991,7 @@ char *llvm::itaniumDemangle(const char *MangledName, char *Buf,
49694991
}
49704992

49714993
int InternalStatus = demangle_success;
4972-
Db Parser(MangledName, MangledName + std::strlen(MangledName));
4994+
Db<> Parser(MangledName, MangledName + std::strlen(MangledName));
49734995
OutputStream S;
49744996

49754997
Node *AST = Parser.parse();
@@ -4995,7 +5017,7 @@ char *llvm::itaniumDemangle(const char *MangledName, char *Buf,
49955017
bool llvm::itaniumFindTypesInMangledName(const char *MangledName, void *Ctx,
49965018
void (*Callback)(void *,
49975019
const char *)) {
4998-
Db Parser(MangledName, MangledName + std::strlen(MangledName));
5020+
Db<> Parser(MangledName, MangledName + std::strlen(MangledName));
49995021
Parser.TypeCallback = Callback;
50005022
Parser.TypeCallbackContext = Ctx;
50015023
return Parser.parse() == nullptr;
@@ -5004,10 +5026,10 @@ bool llvm::itaniumFindTypesInMangledName(const char *MangledName, void *Ctx,
50045026
namespace llvm {
50055027

50065028
ItaniumPartialDemangler::ItaniumPartialDemangler()
5007-
: RootNode(nullptr), Context(new Db{nullptr, nullptr}) {}
5029+
: RootNode(nullptr), Context(new Db<>{nullptr, nullptr}) {}
50085030

50095031
ItaniumPartialDemangler::~ItaniumPartialDemangler() {
5010-
delete static_cast<Db *>(Context);
5032+
delete static_cast<Db<> *>(Context);
50115033
}
50125034

50135035
ItaniumPartialDemangler::ItaniumPartialDemangler(
@@ -5025,7 +5047,7 @@ operator=(ItaniumPartialDemangler &&Other) {
50255047

50265048
// Demangle MangledName into an AST, storing it into this->RootNode.
50275049
bool ItaniumPartialDemangler::partialDemangle(const char *MangledName) {
5028-
Db *Parser = static_cast<Db *>(Context);
5050+
Db<> *Parser = static_cast<Db<> *>(Context);
50295051
size_t Len = std::strlen(MangledName);
50305052
Parser->reset(MangledName, MangledName + Len);
50315053
RootNode = Parser->parse();
@@ -5221,4 +5243,4 @@ bool ItaniumPartialDemangler::isSpecialName() const {
52215243
bool ItaniumPartialDemangler::isData() const {
52225244
return !isFunction() && !isSpecialName();
52235245
}
5224-
}
5246+
} // namespace llvm

0 commit comments

Comments
 (0)
Please sign in to comment.