@@ -278,19 +278,17 @@ class Node {
278
278
}
279
279
280
280
void print (OutputBuffer &OB) const {
281
- printLeft (OB );
281
+ OB. printLeft (* this );
282
282
if (RHSComponentCache != Cache::No)
283
- printRight (OB );
283
+ OB. printRight (* this );
284
284
}
285
285
286
- // Print the "left" side of this Node into OutputBuffer.
287
- virtual void printLeft (OutputBuffer &) const = 0;
288
-
289
- // Print the "right". This distinction is necessary to represent C++ types
290
- // that appear on the RHS of their subtype, such as arrays or functions.
291
- // Since most types don't have such a component, provide a default
292
- // implementation.
293
- virtual void printRight (OutputBuffer &) const {}
286
+ // Print an initializer list of this type. Returns true if we printed a custom
287
+ // representation, false if nothing has been printed and the default
288
+ // representation should be used.
289
+ virtual bool printInitListAsType (OutputBuffer &, const NodeArray &) const {
290
+ return false ;
291
+ }
294
292
295
293
virtual std::string_view getBaseName () const { return {}; }
296
294
@@ -300,6 +298,24 @@ class Node {
300
298
#ifndef NDEBUG
301
299
DEMANGLE_DUMP_METHOD void dump () const ;
302
300
#endif
301
+
302
+ private:
303
+ friend class OutputBuffer ;
304
+
305
+ // Print the "left" side of this Node into OutputBuffer.
306
+ //
307
+ // Note, should only be called from OutputBuffer implementations.
308
+ // Call \ref OutputBuffer::printLeft instead.
309
+ virtual void printLeft (OutputBuffer &) const = 0;
310
+
311
+ // Print the "right". This distinction is necessary to represent C++ types
312
+ // that appear on the RHS of their subtype, such as arrays or functions.
313
+ // Since most types don't have such a component, provide a default
314
+ // implementation.
315
+ //
316
+ // Note, should only be called from OutputBuffer implementations.
317
+ // Call \ref OutputBuffer::printRight instead.
318
+ virtual void printRight (OutputBuffer &) const {}
303
319
};
304
320
305
321
class NodeArray {
@@ -444,11 +460,11 @@ class QualType final : public Node {
444
460
}
445
461
446
462
void printLeft (OutputBuffer &OB) const override {
447
- Child-> printLeft (OB );
463
+ OB. printLeft (*Child );
448
464
printQuals (OB);
449
465
}
450
466
451
- void printRight (OutputBuffer &OB) const override { Child-> printRight (OB ); }
467
+ void printRight (OutputBuffer &OB) const override { OB. printRight (*Child ); }
452
468
};
453
469
454
470
class ConversionOperatorType final : public Node {
@@ -477,7 +493,7 @@ class PostfixQualifiedType final : public Node {
477
493
template <typename Fn> void match (Fn F) const { F (Ty, Postfix); }
478
494
479
495
void printLeft (OutputBuffer &OB) const override {
480
- Ty-> printLeft (OB );
496
+ OB. printLeft (*Ty );
481
497
OB += Postfix;
482
498
}
483
499
};
@@ -563,7 +579,7 @@ struct AbiTagAttr : Node {
563
579
std::string_view getBaseName () const override { return Base->getBaseName (); }
564
580
565
581
void printLeft (OutputBuffer &OB) const override {
566
- Base-> printLeft (OB );
582
+ OB. printLeft (*Base );
567
583
OB += " [abi:" ;
568
584
OB += Tag;
569
585
OB += " ]" ;
@@ -630,7 +646,7 @@ class PointerType final : public Node {
630
646
// We rewrite objc_object<SomeProtocol>* into id<SomeProtocol>.
631
647
if (Pointee->getKind () != KObjCProtoName ||
632
648
!static_cast <const ObjCProtoName *>(Pointee)->isObjCObject ()) {
633
- Pointee-> printLeft (OB );
649
+ OB. printLeft (*Pointee );
634
650
if (Pointee->hasArray (OB))
635
651
OB += " " ;
636
652
if (Pointee->hasArray (OB) || Pointee->hasFunction (OB))
@@ -649,7 +665,7 @@ class PointerType final : public Node {
649
665
!static_cast <const ObjCProtoName *>(Pointee)->isObjCObject ()) {
650
666
if (Pointee->hasArray (OB) || Pointee->hasFunction (OB))
651
667
OB += " )" ;
652
- Pointee-> printRight (OB );
668
+ OB. printRight (*Pointee );
653
669
}
654
670
}
655
671
};
@@ -715,7 +731,7 @@ class ReferenceType : public Node {
715
731
std::pair<ReferenceKind, const Node *> Collapsed = collapse (OB);
716
732
if (!Collapsed.second )
717
733
return ;
718
- Collapsed. second -> printLeft (OB );
734
+ OB. printLeft (*Collapsed. second );
719
735
if (Collapsed.second ->hasArray (OB))
720
736
OB += " " ;
721
737
if (Collapsed.second ->hasArray (OB) || Collapsed.second ->hasFunction (OB))
@@ -732,7 +748,7 @@ class ReferenceType : public Node {
732
748
return ;
733
749
if (Collapsed.second ->hasArray (OB) || Collapsed.second ->hasFunction (OB))
734
750
OB += " )" ;
735
- Collapsed. second -> printRight (OB );
751
+ OB. printRight (*Collapsed. second );
736
752
}
737
753
};
738
754
@@ -752,7 +768,7 @@ class PointerToMemberType final : public Node {
752
768
}
753
769
754
770
void printLeft (OutputBuffer &OB) const override {
755
- MemberType-> printLeft (OB );
771
+ OB. printLeft (*MemberType );
756
772
if (MemberType->hasArray (OB) || MemberType->hasFunction (OB))
757
773
OB += " (" ;
758
774
else
@@ -764,7 +780,7 @@ class PointerToMemberType final : public Node {
764
780
void printRight (OutputBuffer &OB) const override {
765
781
if (MemberType->hasArray (OB) || MemberType->hasFunction (OB))
766
782
OB += " )" ;
767
- MemberType-> printRight (OB );
783
+ OB. printRight (*MemberType );
768
784
}
769
785
};
770
786
@@ -784,7 +800,7 @@ class ArrayType final : public Node {
784
800
bool hasRHSComponentSlow (OutputBuffer &) const override { return true ; }
785
801
bool hasArraySlow (OutputBuffer &) const override { return true ; }
786
802
787
- void printLeft (OutputBuffer &OB) const override { Base-> printLeft (OB ); }
803
+ void printLeft (OutputBuffer &OB) const override { OB. printLeft (*Base ); }
788
804
789
805
void printRight (OutputBuffer &OB) const override {
790
806
if (OB.back () != ' ]' )
@@ -793,7 +809,7 @@ class ArrayType final : public Node {
793
809
if (Dimension)
794
810
Dimension->print (OB);
795
811
OB += " ]" ;
796
- Base-> printRight (OB );
812
+ OB. printRight (*Base );
797
813
}
798
814
};
799
815
@@ -828,15 +844,15 @@ class FunctionType final : public Node {
828
844
// by printing out the return types's left, then print our parameters, then
829
845
// finally print right of the return type.
830
846
void printLeft (OutputBuffer &OB) const override {
831
- Ret-> printLeft (OB );
847
+ OB. printLeft (*Ret );
832
848
OB += " " ;
833
849
}
834
850
835
851
void printRight (OutputBuffer &OB) const override {
836
852
OB.printOpen ();
837
853
Params.printWithComma (OB);
838
854
OB.printClose ();
839
- Ret-> printRight (OB );
855
+ OB. printRight (*Ret );
840
856
841
857
if (CVQuals & QualConst)
842
858
OB += " const" ;
@@ -941,6 +957,8 @@ class FunctionEncoding final : public Node {
941
957
FunctionRefQual getRefQual () const { return RefQual; }
942
958
NodeArray getParams () const { return Params; }
943
959
const Node *getReturnType () const { return Ret; }
960
+ const Node *getAttrs () const { return Attrs; }
961
+ const Node *getRequires () const { return Requires; }
944
962
945
963
bool hasRHSComponentSlow (OutputBuffer &) const override { return true ; }
946
964
bool hasFunctionSlow (OutputBuffer &) const override { return true ; }
@@ -949,19 +967,21 @@ class FunctionEncoding final : public Node {
949
967
950
968
void printLeft (OutputBuffer &OB) const override {
951
969
if (Ret) {
952
- Ret-> printLeft (OB );
970
+ OB. printLeft (*Ret );
953
971
if (!Ret->hasRHSComponent (OB))
954
972
OB += " " ;
955
973
}
974
+
956
975
Name->print (OB);
957
976
}
958
977
959
978
void printRight (OutputBuffer &OB) const override {
960
979
OB.printOpen ();
961
980
Params.printWithComma (OB);
962
981
OB.printClose ();
982
+
963
983
if (Ret)
964
- Ret-> printRight (OB );
984
+ OB. printRight (*Ret );
965
985
966
986
if (CVQuals & QualConst)
967
987
OB += " const" ;
@@ -1301,14 +1321,14 @@ class NonTypeTemplateParamDecl final : public Node {
1301
1321
template <typename Fn> void match (Fn F) const { F (Name, Type); }
1302
1322
1303
1323
void printLeft (OutputBuffer &OB) const override {
1304
- Type-> printLeft (OB );
1324
+ OB. printLeft (*Type );
1305
1325
if (!Type->hasRHSComponent (OB))
1306
1326
OB += " " ;
1307
1327
}
1308
1328
1309
1329
void printRight (OutputBuffer &OB) const override {
1310
1330
Name->print (OB);
1311
- Type-> printRight (OB );
1331
+ OB. printRight (*Type );
1312
1332
}
1313
1333
};
1314
1334
@@ -1353,11 +1373,11 @@ class TemplateParamPackDecl final : public Node {
1353
1373
template <typename Fn> void match (Fn F) const { F (Param); }
1354
1374
1355
1375
void printLeft (OutputBuffer &OB) const override {
1356
- Param-> printLeft (OB );
1376
+ OB. printLeft (*Param );
1357
1377
OB += " ..." ;
1358
1378
}
1359
1379
1360
- void printRight (OutputBuffer &OB) const override { Param-> printRight (OB ); }
1380
+ void printRight (OutputBuffer &OB) const override { OB. printRight (*Param ); }
1361
1381
};
1362
1382
1363
1383
// / An unexpanded parameter pack (either in the expression or type context). If
@@ -1424,13 +1444,13 @@ class ParameterPack final : public Node {
1424
1444
initializePackExpansion (OB);
1425
1445
size_t Idx = OB.CurrentPackIndex ;
1426
1446
if (Idx < Data.size ())
1427
- Data[Idx]-> printLeft (OB );
1447
+ OB. printLeft (* Data[Idx]);
1428
1448
}
1429
1449
void printRight (OutputBuffer &OB) const override {
1430
1450
initializePackExpansion (OB);
1431
1451
size_t Idx = OB.CurrentPackIndex ;
1432
1452
if (Idx < Data.size ())
1433
- Data[Idx]-> printRight (OB );
1453
+ OB. printRight (* Data[Idx]);
1434
1454
}
1435
1455
};
1436
1456
@@ -1588,13 +1608,13 @@ struct ForwardTemplateReference : Node {
1588
1608
if (Printing)
1589
1609
return ;
1590
1610
ScopedOverride<bool > SavePrinting (Printing, true );
1591
- Ref-> printLeft (OB );
1611
+ OB. printLeft (*Ref );
1592
1612
}
1593
1613
void printRight (OutputBuffer &OB) const override {
1594
1614
if (Printing)
1595
1615
return ;
1596
1616
ScopedOverride<bool > SavePrinting (Printing, true );
1597
- Ref-> printRight (OB );
1617
+ OB. printRight (*Ref );
1598
1618
}
1599
1619
};
1600
1620
@@ -1746,7 +1766,7 @@ class DtorName : public Node {
1746
1766
1747
1767
void printLeft (OutputBuffer &OB) const override {
1748
1768
OB += " ~" ;
1749
- Base-> printLeft (OB );
1769
+ OB. printLeft (*Base );
1750
1770
}
1751
1771
};
1752
1772
@@ -2026,7 +2046,7 @@ class CastExpr : public Node {
2026
2046
{
2027
2047
ScopedOverride<unsigned > LT (OB.GtIsGt , 0 );
2028
2048
OB += " <" ;
2029
- To-> printLeft (OB );
2049
+ OB. printLeft (*To );
2030
2050
OB += " >" ;
2031
2051
}
2032
2052
OB.printOpen ();
@@ -5946,6 +5966,10 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {
5946
5966
Alloc>::AbstractManglingParser;
5947
5967
};
5948
5968
5969
+ inline void OutputBuffer::printLeft (const Node &N) { N.printLeft (*this ); }
5970
+
5971
+ inline void OutputBuffer::printRight (const Node &N) { N.printRight (*this ); }
5972
+
5949
5973
DEMANGLE_NAMESPACE_END
5950
5974
5951
5975
#ifdef _LIBCXXABI_COMPILER_CLANG
0 commit comments