@@ -1942,6 +1942,23 @@ class PODSmallVector {
1942
1942
}
1943
1943
};
1944
1944
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>
1945
1962
struct Db {
1946
1963
const char *First;
1947
1964
const char *Last;
@@ -1972,7 +1989,7 @@ struct Db {
1972
1989
bool PermitForwardTemplateReferences = false ;
1973
1990
bool ParsingLambdaParams = false ;
1974
1991
1975
- BumpPointerAllocator ASTAllocator;
1992
+ Alloc ASTAllocator;
1976
1993
1977
1994
Db (const char *First_, const char *Last_) : First(First_), Last(Last_) {}
1978
1995
@@ -1989,13 +2006,12 @@ struct Db {
1989
2006
}
1990
2007
1991
2008
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)...);
1994
2010
}
1995
2011
1996
2012
template <class It > NodeArray makeNodeArray (It begin, It end) {
1997
2013
size_t sz = static_cast <size_t >(end - begin);
1998
- void *mem = ASTAllocator.allocate ( sizeof (Node *) * sz);
2014
+ void *mem = ASTAllocator.allocateNodeArray ( sz);
1999
2015
Node **data = new (mem) Node *[sz];
2000
2016
std::copy (begin, end, data);
2001
2017
return NodeArray (data, sz);
@@ -2132,7 +2148,7 @@ const char* parse_discriminator(const char* first, const char* last);
2132
2148
//
2133
2149
// <unscoped-template-name> ::= <unscoped-name>
2134
2150
// ::= <substitution>
2135
- Node *Db::parseName (NameState *State) {
2151
+ template < typename Alloc> Node *Db<Alloc> ::parseName(NameState *State) {
2136
2152
consumeIf (' L' ); // extension
2137
2153
2138
2154
if (look () == ' N' )
@@ -2173,7 +2189,7 @@ Node *Db::parseName(NameState *State) {
2173
2189
// <local-name> := Z <function encoding> E <entity name> [<discriminator>]
2174
2190
// := Z <function encoding> E s [<discriminator>]
2175
2191
// := Z <function encoding> Ed [ <parameter number> ] _ <entity name>
2176
- Node *Db::parseLocalName (NameState *State) {
2192
+ template < typename Alloc> Node *Db<Alloc> ::parseLocalName(NameState *State) {
2177
2193
if (!consumeIf (' Z' ))
2178
2194
return nullptr ;
2179
2195
Node *Encoding = parseEncoding ();
@@ -2205,7 +2221,7 @@ Node *Db::parseLocalName(NameState *State) {
2205
2221
// <unscoped-name> ::= <unqualified-name>
2206
2222
// ::= St <unqualified-name> # ::std::
2207
2223
// extension ::= StL<unqualified-name>
2208
- Node *Db::parseUnscopedName (NameState *State) {
2224
+ template < typename Alloc> Node *Db<Alloc> ::parseUnscopedName(NameState *State) {
2209
2225
if (consumeIf (" StL" ) || consumeIf (" St" )) {
2210
2226
Node *R = parseUnqualifiedName (State);
2211
2227
if (R == nullptr )
@@ -2220,27 +2236,28 @@ Node *Db::parseUnscopedName(NameState *State) {
2220
2236
// ::= <source-name>
2221
2237
// ::= <unnamed-type-name>
2222
2238
// ::= 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;
2244
2261
}
2245
2262
2246
2263
// <unnamed-type-name> ::= Ut [<nonnegative number>] _
@@ -2249,7 +2266,7 @@ Node *Db::parseUnqualifiedName(NameState *State) {
2249
2266
// <closure-type-name> ::= Ul <lambda-sig> E [ <nonnegative number> ] _
2250
2267
//
2251
2268
// <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 *) {
2253
2270
if (consumeIf (" Ut" )) {
2254
2271
StringView Count = parseNumber ();
2255
2272
if (!consumeIf (' _' ))
@@ -2278,7 +2295,7 @@ Node *Db::parseUnnamedTypeName(NameState *) {
2278
2295
}
2279
2296
2280
2297
// <source-name> ::= <positive length number> <identifier>
2281
- Node *Db::parseSourceName (NameState *) {
2298
+ template < typename Alloc> Node *Db<Alloc> ::parseSourceName(NameState *) {
2282
2299
size_t Length = 0 ;
2283
2300
if (parsePositiveInteger (&Length))
2284
2301
return nullptr ;
@@ -2342,7 +2359,7 @@ Node *Db::parseSourceName(NameState *) {
2342
2359
// ::= rS # >>=
2343
2360
// ::= ss # <=> C++2a
2344
2361
// ::= v <digit> <source-name> # vendor extended operator
2345
- Node *Db::parseOperatorName (NameState *State) {
2362
+ template < typename Alloc> Node *Db<Alloc> ::parseOperatorName(NameState *State) {
2346
2363
switch (look ()) {
2347
2364
case ' a' :
2348
2365
switch (look (1 )) {
@@ -2585,7 +2602,8 @@ Node *Db::parseOperatorName(NameState *State) {
2585
2602
// ::= D1 # complete object destructor
2586
2603
// ::= D2 # base object destructor
2587
2604
// extension ::= D5 # ?
2588
- Node *Db::parseCtorDtorName (Node *&SoFar, NameState *State) {
2605
+ template <typename Alloc>
2606
+ Node *Db<Alloc>::parseCtorDtorName(Node *&SoFar, NameState *State) {
2589
2607
if (SoFar->K == Node::KSpecialSubstitution) {
2590
2608
auto SSK = static_cast <SpecialSubstitution *>(SoFar)->SSK ;
2591
2609
switch (SSK) {
@@ -2639,7 +2657,7 @@ Node *Db::parseCtorDtorName(Node *&SoFar, NameState *State) {
2639
2657
// <template-prefix> ::= <prefix> <template unqualified-name>
2640
2658
// ::= <template-param>
2641
2659
// ::= <substitution>
2642
- Node *Db::parseNestedName (NameState *State) {
2660
+ template < typename Alloc> Node *Db<Alloc> ::parseNestedName(NameState *State) {
2643
2661
if (!consumeIf (' N' ))
2644
2662
return nullptr ;
2645
2663
@@ -2746,7 +2764,7 @@ Node *Db::parseNestedName(NameState *State) {
2746
2764
}
2747
2765
2748
2766
// <simple-id> ::= <source-name> [ <template-args> ]
2749
- Node *Db::parseSimpleId () {
2767
+ template < typename Alloc> Node *Db<Alloc> ::parseSimpleId() {
2750
2768
Node *SN = parseSourceName (/* NameState=*/ nullptr );
2751
2769
if (SN == nullptr )
2752
2770
return nullptr ;
@@ -2761,7 +2779,7 @@ Node *Db::parseSimpleId() {
2761
2779
2762
2780
// <destructor-name> ::= <unresolved-type> # e.g., ~T or ~decltype(f())
2763
2781
// ::= <simple-id> # e.g., ~A<2*N>
2764
- Node *Db::parseDestructorName () {
2782
+ template < typename Alloc> Node *Db<Alloc> ::parseDestructorName() {
2765
2783
Node *Result;
2766
2784
if (std::isdigit (look ()))
2767
2785
Result = parseSimpleId ();
@@ -2775,7 +2793,7 @@ Node *Db::parseDestructorName() {
2775
2793
// <unresolved-type> ::= <template-param>
2776
2794
// ::= <decltype>
2777
2795
// ::= <substitution>
2778
- Node *Db::parseUnresolvedType () {
2796
+ template < typename Alloc> Node *Db<Alloc> ::parseUnresolvedType() {
2779
2797
if (look () == ' T' ) {
2780
2798
Node *TP = parseTemplateParam ();
2781
2799
if (TP == nullptr )
@@ -2800,7 +2818,7 @@ Node *Db::parseUnresolvedType() {
2800
2818
// ::= on <operator-name> <template-args> # unresolved operator template-id
2801
2819
// ::= dn <destructor-name> # destructor or pseudo-destructor;
2802
2820
// # e.g. ~X or ~X<N-1>
2803
- Node *Db::parseBaseUnresolvedName () {
2821
+ template < typename Alloc> Node *Db<Alloc> ::parseBaseUnresolvedName() {
2804
2822
if (std::isdigit (look ()))
2805
2823
return parseSimpleId ();
2806
2824
@@ -2832,7 +2850,7 @@ Node *Db::parseBaseUnresolvedName() {
2832
2850
// (ignored) ::= srN <unresolved-type> <unresolved-qualifier-level>+ E <base-unresolved-name>
2833
2851
//
2834
2852
// <unresolved-qualifier-level> ::= <simple-id>
2835
- Node *Db::parseUnresolvedName () {
2853
+ template < typename Alloc> Node *Db<Alloc> ::parseUnresolvedName() {
2836
2854
Node *SoFar = nullptr ;
2837
2855
2838
2856
// srN <unresolved-type> [<template-args>] <unresolved-qualifier-level>* E <base-unresolved-name>
@@ -2913,7 +2931,7 @@ Node *Db::parseUnresolvedName() {
2913
2931
2914
2932
// <abi-tags> ::= <abi-tag> [<abi-tags>]
2915
2933
// <abi-tag> ::= B <source-name>
2916
- Node *Db::parseAbiTags (Node *N) {
2934
+ template < typename Alloc> Node *Db<Alloc> ::parseAbiTags(Node *N) {
2917
2935
while (consumeIf (' B' )) {
2918
2936
StringView SN = parseBareSourceName ();
2919
2937
if (SN.empty ())
@@ -2924,7 +2942,8 @@ Node *Db::parseAbiTags(Node *N) {
2924
2942
}
2925
2943
2926
2944
// <number> ::= [n] <non-negative decimal integer>
2927
- StringView Db::parseNumber (bool AllowNegative) {
2945
+ template <typename Alloc>
2946
+ StringView Db<Alloc>::parseNumber(bool AllowNegative) {
2928
2947
const char *Tmp = First;
2929
2948
if (AllowNegative)
2930
2949
consumeIf (' n' );
@@ -2936,7 +2955,7 @@ StringView Db::parseNumber(bool AllowNegative) {
2936
2955
}
2937
2956
2938
2957
// <positive length number> ::= [0-9]*
2939
- bool Db::parsePositiveInteger (size_t *Out) {
2958
+ template < typename Alloc> bool Db<Alloc> ::parsePositiveInteger(size_t *Out) {
2940
2959
*Out = 0 ;
2941
2960
if (look () < ' 0' || look () > ' 9' )
2942
2961
return true ;
@@ -2947,7 +2966,7 @@ bool Db::parsePositiveInteger(size_t *Out) {
2947
2966
return false ;
2948
2967
}
2949
2968
2950
- StringView Db::parseBareSourceName () {
2969
+ template < typename Alloc> StringView Db<Alloc> ::parseBareSourceName() {
2951
2970
size_t Int = 0 ;
2952
2971
if (parsePositiveInteger (&Int) || numLeft () < Int)
2953
2972
return StringView ();
@@ -2964,7 +2983,7 @@ StringView Db::parseBareSourceName() {
2964
2983
//
2965
2984
// <ref-qualifier> ::= R # & ref-qualifier
2966
2985
// <ref-qualifier> ::= O # && ref-qualifier
2967
- Node *Db::parseFunctionType () {
2986
+ template < typename Alloc> Node *Db<Alloc> ::parseFunctionType() {
2968
2987
Qualifiers CVQuals = parseCVQualifiers ();
2969
2988
2970
2989
Node *ExceptionSpec = nullptr ;
@@ -3027,7 +3046,7 @@ Node *Db::parseFunctionType() {
3027
3046
// ::= Dv [<dimension expression>] _ <element type>
3028
3047
// <extended element type> ::= <element type>
3029
3048
// ::= p # AltiVec vector pixel
3030
- Node *Db::parseVectorType () {
3049
+ template < typename Alloc> Node *Db<Alloc> ::parseVectorType() {
3031
3050
if (!consumeIf (" Dv" ))
3032
3051
return nullptr ;
3033
3052
if (look () >= ' 1' && look () <= ' 9' ) {
@@ -3061,7 +3080,7 @@ Node *Db::parseVectorType() {
3061
3080
3062
3081
// <decltype> ::= Dt <expression> E # decltype of an id-expression or class member access (C++0x)
3063
3082
// ::= DT <expression> E # decltype of an expression (C++0x)
3064
- Node *Db::parseDecltype () {
3083
+ template < typename Alloc> Node *Db<Alloc> ::parseDecltype() {
3065
3084
if (!consumeIf (' D' ))
3066
3085
return nullptr ;
3067
3086
if (!consumeIf (' t' ) && !consumeIf (' T' ))
@@ -3076,7 +3095,7 @@ Node *Db::parseDecltype() {
3076
3095
3077
3096
// <array-type> ::= A <positive dimension number> _ <element type>
3078
3097
// ::= A [<dimension expression>] _ <element type>
3079
- Node *Db::parseArrayType () {
3098
+ template < typename Alloc> Node *Db<Alloc> ::parseArrayType() {
3080
3099
if (!consumeIf (' A' ))
3081
3100
return nullptr ;
3082
3101
@@ -3109,7 +3128,7 @@ Node *Db::parseArrayType() {
3109
3128
}
3110
3129
3111
3130
// <pointer-to-member-type> ::= M <class type> <member type>
3112
- Node *Db::parsePointerToMemberType () {
3131
+ template < typename Alloc> Node *Db<Alloc> ::parsePointerToMemberType() {
3113
3132
if (!consumeIf (' M' ))
3114
3133
return nullptr ;
3115
3134
Node *ClassType = parseType ();
@@ -3125,7 +3144,7 @@ Node *Db::parsePointerToMemberType() {
3125
3144
// ::= Ts <name> # dependent elaborated type specifier using 'struct' or 'class'
3126
3145
// ::= Tu <name> # dependent elaborated type specifier using 'union'
3127
3146
// ::= Te <name> # dependent elaborated type specifier using 'enum'
3128
- Node *Db::parseClassEnumType () {
3147
+ template < typename Alloc> Node *Db<Alloc> ::parseClassEnumType() {
3129
3148
StringView ElabSpef;
3130
3149
if (consumeIf (" Ts" ))
3131
3150
ElabSpef = " struct" ;
@@ -3147,7 +3166,7 @@ Node *Db::parseClassEnumType() {
3147
3166
// <qualified-type> ::= <qualifiers> <type>
3148
3167
// <qualifiers> ::= <extended-qualifier>* <CV-qualifiers>
3149
3168
// <extended-qualifier> ::= U <source-name> [<template-args>] # vendor extended type qualifier
3150
- Node *Db::parseQualifiedType () {
3169
+ template < typename Alloc> Node *Db<Alloc> ::parseQualifiedType() {
3151
3170
if (consumeIf (' U' )) {
3152
3171
StringView Qual = parseBareSourceName ();
3153
3172
if (Qual.empty ())
@@ -3207,7 +3226,7 @@ Node *Db::parseQualifiedType() {
3207
3226
//
3208
3227
// <objc-name> ::= <k0 number> objcproto <k1 number> <identifier> # k0 = 9 + <number of digits in k1> + k1
3209
3228
// <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() {
3211
3230
Node *Result = nullptr ;
3212
3231
3213
3232
if (TypeCallback != nullptr )
@@ -3534,14 +3553,14 @@ Node *Db::parseType() {
3534
3553
return Result;
3535
3554
}
3536
3555
3537
- Node *Db::parsePrefixExpr (StringView Kind) {
3556
+ template < typename Alloc> Node *Db<Alloc> ::parsePrefixExpr(StringView Kind) {
3538
3557
Node *E = parseExpr ();
3539
3558
if (E == nullptr )
3540
3559
return nullptr ;
3541
3560
return make<PrefixExpr>(Kind, E);
3542
3561
}
3543
3562
3544
- Node *Db::parseBinaryExpr (StringView Kind) {
3563
+ template < typename Alloc> Node *Db<Alloc> ::parseBinaryExpr(StringView Kind) {
3545
3564
Node *LHS = parseExpr ();
3546
3565
if (LHS == nullptr )
3547
3566
return nullptr ;
@@ -3551,15 +3570,15 @@ Node *Db::parseBinaryExpr(StringView Kind) {
3551
3570
return make<BinaryExpr>(LHS, Kind, RHS);
3552
3571
}
3553
3572
3554
- Node *Db::parseIntegerLiteral (StringView Lit) {
3573
+ template < typename Alloc> Node *Db<Alloc> ::parseIntegerLiteral(StringView Lit) {
3555
3574
StringView Tmp = parseNumber (true );
3556
3575
if (!Tmp.empty () && consumeIf (' E' ))
3557
3576
return make<IntegerExpr>(Lit, Tmp);
3558
3577
return nullptr ;
3559
3578
}
3560
3579
3561
3580
// <CV-Qualifiers> ::= [r] [V] [K]
3562
- Qualifiers Db::parseCVQualifiers () {
3581
+ template < typename Alloc> Qualifiers Db<Alloc> ::parseCVQualifiers() {
3563
3582
Qualifiers CVR = QualNone;
3564
3583
if (consumeIf (' r' ))
3565
3584
addQualifiers (CVR, QualRestrict);
@@ -3574,7 +3593,7 @@ Qualifiers Db::parseCVQualifiers() {
3574
3593
// ::= fp <top-level CV-Qualifiers> <parameter-2 non-negative number> _ # L == 0, second and later parameters
3575
3594
// ::= fL <L-1 non-negative number> p <top-level CV-Qualifiers> _ # L > 0, first parameter
3576
3595
// ::= 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() {
3578
3597
if (consumeIf (" fp" )) {
3579
3598
parseCVQualifiers ();
3580
3599
StringView Num = parseNumber ();
@@ -3601,7 +3620,7 @@ Node *Db::parseFunctionParam() {
3601
3620
// [gs] na <expression>* _ <type> E # new[] (expr-list) type
3602
3621
// [gs] na <expression>* _ <type> <initializer> # new[] (expr-list) type (init)
3603
3622
// <initializer> ::= pi <expression>* E # parenthesized initialization
3604
- Node *Db::parseNewExpr () {
3623
+ template < typename Alloc> Node *Db<Alloc> ::parseNewExpr() {
3605
3624
bool Global = consumeIf (" gs" );
3606
3625
bool IsArray = look (1 ) == ' a' ;
3607
3626
if (!consumeIf (" nw" ) && !consumeIf (" na" ))
@@ -3634,7 +3653,7 @@ Node *Db::parseNewExpr() {
3634
3653
3635
3654
// cv <type> <expression> # conversion with one argument
3636
3655
// cv <type> _ <expression>* E # conversion with a different number of arguments
3637
- Node *Db::parseConversionExpr () {
3656
+ template < typename Alloc> Node *Db<Alloc> ::parseConversionExpr() {
3638
3657
if (!consumeIf (" cv" ))
3639
3658
return nullptr ;
3640
3659
Node *Ty;
@@ -3670,7 +3689,7 @@ Node *Db::parseConversionExpr() {
3670
3689
// ::= L <nullptr type> E # nullptr literal (i.e., "LDnE")
3671
3690
// FIXME: ::= L <type> <real-part float> _ <imag-part float> E # complex floating point literal (C 2000)
3672
3691
// ::= L <mangled-name> E # external name
3673
- Node *Db::parseExprPrimary () {
3692
+ template < typename Alloc> Node *Db<Alloc> ::parseExprPrimary() {
3674
3693
if (!consumeIf (' L' ))
3675
3694
return nullptr ;
3676
3695
switch (look ()) {
@@ -3764,7 +3783,7 @@ Node *Db::parseExprPrimary() {
3764
3783
// ::= di <field source-name> <braced-expression> # .name = expr
3765
3784
// ::= dx <index expression> <braced-expression> # [expr] = expr
3766
3785
// ::= dX <range begin expression> <range end expression> <braced-expression>
3767
- Node *Db::parseBracedExpr () {
3786
+ template < typename Alloc> Node *Db<Alloc> ::parseBracedExpr() {
3768
3787
if (look () == ' d' ) {
3769
3788
switch (look (1 )) {
3770
3789
case ' i' : {
@@ -3810,7 +3829,7 @@ Node *Db::parseBracedExpr() {
3810
3829
// ::= fR <binary-operator-name> <expression> <expression>
3811
3830
// ::= fl <binary-operator-name> <expression>
3812
3831
// ::= fr <binary-operator-name> <expression>
3813
- Node *Db::parseFoldExpr () {
3832
+ template < typename Alloc> Node *Db<Alloc> ::parseFoldExpr() {
3814
3833
if (!consumeIf (' f' ))
3815
3834
return nullptr ;
3816
3835
@@ -3919,7 +3938,7 @@ Node *Db::parseFoldExpr() {
3919
3938
// ::= fl <binary-operator-name> <expression>
3920
3939
// ::= fr <binary-operator-name> <expression>
3921
3940
// ::= <expr-primary>
3922
- Node *Db::parseExpr () {
3941
+ template < typename Alloc> Node *Db<Alloc> ::parseExpr() {
3923
3942
bool Global = consumeIf (" gs" );
3924
3943
if (numLeft () < 2 )
3925
3944
return nullptr ;
@@ -4394,7 +4413,7 @@ Node *Db::parseExpr() {
4394
4413
//
4395
4414
// <v-offset> ::= <offset number> _ <virtual offset number>
4396
4415
// # virtual base override, with vcall offset
4397
- bool Db::parseCallOffset () {
4416
+ template < typename Alloc> bool Db<Alloc> ::parseCallOffset() {
4398
4417
// Just scan through the call offset, we never add this information into the
4399
4418
// output.
4400
4419
if (consumeIf (' h' ))
@@ -4423,7 +4442,7 @@ bool Db::parseCallOffset() {
4423
4442
// ::= GR <object name> <seq-id> _ # Subsequent temporaries
4424
4443
// extension ::= TC <first type> <number> _ <second type> # construction vtable for second-in-first
4425
4444
// extension ::= GR <object name> # reference temporary for object
4426
- Node *Db::parseSpecialName () {
4445
+ template < typename Alloc> Node *Db<Alloc> ::parseSpecialName() {
4427
4446
switch (look ()) {
4428
4447
case ' T' :
4429
4448
switch (look (1 )) {
@@ -4546,7 +4565,7 @@ Node *Db::parseSpecialName() {
4546
4565
// <encoding> ::= <function name> <bare-function-type>
4547
4566
// ::= <data name>
4548
4567
// ::= <special-name>
4549
- Node *Db::parseEncoding () {
4568
+ template < typename Alloc> Node *Db<Alloc> ::parseEncoding() {
4550
4569
if (look () == ' G' || look () == ' T' )
4551
4570
return parseSpecialName ();
4552
4571
@@ -4646,7 +4665,9 @@ struct FloatData<long double>
4646
4665
4647
4666
constexpr const char *FloatData<long double >::spec;
4648
4667
4649
- template <class Float > Node *Db::parseFloatingLiteral () {
4668
+ template <typename Alloc>
4669
+ template <class Float >
4670
+ Node *Db<Alloc>::parseFloatingLiteral() {
4650
4671
const size_t N = FloatData<Float>::mangled_size;
4651
4672
if (numLeft () <= N)
4652
4673
return nullptr ;
@@ -4661,7 +4682,7 @@ template <class Float> Node *Db::parseFloatingLiteral() {
4661
4682
}
4662
4683
4663
4684
// <seq-id> ::= <0-9A-Z>+
4664
- bool Db::parseSeqId (size_t *Out) {
4685
+ template < typename Alloc> bool Db<Alloc> ::parseSeqId(size_t *Out) {
4665
4686
if (!(look () >= ' 0' && look () <= ' 9' ) &&
4666
4687
!(look () >= ' A' && look () <= ' Z' ))
4667
4688
return true ;
@@ -4692,7 +4713,7 @@ bool Db::parseSeqId(size_t *Out) {
4692
4713
// <substitution> ::= Si # ::std::basic_istream<char, std::char_traits<char> >
4693
4714
// <substitution> ::= So # ::std::basic_ostream<char, std::char_traits<char> >
4694
4715
// <substitution> ::= Sd # ::std::basic_iostream<char, std::char_traits<char> >
4695
- Node *Db::parseSubstitution () {
4716
+ template < typename Alloc> Node *Db<Alloc> ::parseSubstitution() {
4696
4717
if (!consumeIf (' S' ))
4697
4718
return nullptr ;
4698
4719
@@ -4756,7 +4777,7 @@ Node *Db::parseSubstitution() {
4756
4777
4757
4778
// <template-param> ::= T_ # first template parameter
4758
4779
// ::= T <parameter-2 non-negative number> _
4759
- Node *Db::parseTemplateParam () {
4780
+ template < typename Alloc> Node *Db<Alloc> ::parseTemplateParam() {
4760
4781
if (!consumeIf (' T' ))
4761
4782
return nullptr ;
4762
4783
@@ -4792,7 +4813,7 @@ Node *Db::parseTemplateParam() {
4792
4813
// ::= <expr-primary> # simple expressions
4793
4814
// ::= J <template-arg>* E # argument pack
4794
4815
// ::= LZ <encoding> E # extension
4795
- Node *Db::parseTemplateArg () {
4816
+ template < typename Alloc> Node *Db<Alloc> ::parseTemplateArg() {
4796
4817
switch (look ()) {
4797
4818
case ' X' : {
4798
4819
++First;
@@ -4832,7 +4853,8 @@ Node *Db::parseTemplateArg() {
4832
4853
4833
4854
// <template-args> ::= I <template-arg>* E
4834
4855
// extension, the abi says <template-arg>+
4835
- Node *Db::parseTemplateArgs (bool TagTemplates) {
4856
+ template <typename Alloc>
4857
+ Node *Db<Alloc>::parseTemplateArgs(bool TagTemplates) {
4836
4858
if (!consumeIf (' I' ))
4837
4859
return nullptr ;
4838
4860
@@ -4909,7 +4931,7 @@ parse_discriminator(const char* first, const char* last)
4909
4931
// extension ::= ___Z <encoding> _block_invoke
4910
4932
// extension ::= ___Z <encoding> _block_invoke<decimal-digit>+
4911
4933
// extension ::= ___Z <encoding> _block_invoke_<decimal-digit>+
4912
- Node *Db::parse () {
4934
+ template < typename Alloc> Node *Db<Alloc> ::parse() {
4913
4935
if (consumeIf (" _Z" )) {
4914
4936
Node *Encoding = parseEncoding ();
4915
4937
if (Encoding == nullptr )
@@ -4969,7 +4991,7 @@ char *llvm::itaniumDemangle(const char *MangledName, char *Buf,
4969
4991
}
4970
4992
4971
4993
int InternalStatus = demangle_success;
4972
- Db Parser (MangledName, MangledName + std::strlen (MangledName));
4994
+ Db<> Parser (MangledName, MangledName + std::strlen (MangledName));
4973
4995
OutputStream S;
4974
4996
4975
4997
Node *AST = Parser.parse ();
@@ -4995,7 +5017,7 @@ char *llvm::itaniumDemangle(const char *MangledName, char *Buf,
4995
5017
bool llvm::itaniumFindTypesInMangledName (const char *MangledName, void *Ctx,
4996
5018
void (*Callback)(void *,
4997
5019
const char *)) {
4998
- Db Parser (MangledName, MangledName + std::strlen (MangledName));
5020
+ Db<> Parser (MangledName, MangledName + std::strlen (MangledName));
4999
5021
Parser.TypeCallback = Callback;
5000
5022
Parser.TypeCallbackContext = Ctx;
5001
5023
return Parser.parse () == nullptr ;
@@ -5004,10 +5026,10 @@ bool llvm::itaniumFindTypesInMangledName(const char *MangledName, void *Ctx,
5004
5026
namespace llvm {
5005
5027
5006
5028
ItaniumPartialDemangler::ItaniumPartialDemangler ()
5007
- : RootNode(nullptr ), Context(new Db{nullptr , nullptr }) {}
5029
+ : RootNode(nullptr ), Context(new Db<> {nullptr , nullptr }) {}
5008
5030
5009
5031
ItaniumPartialDemangler::~ItaniumPartialDemangler () {
5010
- delete static_cast <Db *>(Context);
5032
+ delete static_cast <Db<> *>(Context);
5011
5033
}
5012
5034
5013
5035
ItaniumPartialDemangler::ItaniumPartialDemangler (
@@ -5025,7 +5047,7 @@ operator=(ItaniumPartialDemangler &&Other) {
5025
5047
5026
5048
// Demangle MangledName into an AST, storing it into this->RootNode.
5027
5049
bool ItaniumPartialDemangler::partialDemangle (const char *MangledName) {
5028
- Db *Parser = static_cast <Db *>(Context);
5050
+ Db<> *Parser = static_cast <Db<> *>(Context);
5029
5051
size_t Len = std::strlen (MangledName);
5030
5052
Parser->reset (MangledName, MangledName + Len);
5031
5053
RootNode = Parser->parse ();
@@ -5221,4 +5243,4 @@ bool ItaniumPartialDemangler::isSpecialName() const {
5221
5243
bool ItaniumPartialDemangler::isData () const {
5222
5244
return !isFunction () && !isSpecialName ();
5223
5245
}
5224
- }
5246
+ } // namespace llvm
0 commit comments