@@ -281,20 +281,11 @@ class Node {
281
281
}
282
282
283
283
void print (OutputBuffer &OB) const {
284
- printLeft (OB );
284
+ OB. printLeft (* this );
285
285
if (RHSComponentCache != Cache::No)
286
- printRight (OB );
286
+ OB. printRight (* this );
287
287
}
288
288
289
- // Print the "left" side of this Node into OutputBuffer.
290
- virtual void printLeft (OutputBuffer &) const = 0;
291
-
292
- // Print the "right". This distinction is necessary to represent C++ types
293
- // that appear on the RHS of their subtype, such as arrays or functions.
294
- // Since most types don't have such a component, provide a default
295
- // implementation.
296
- virtual void printRight (OutputBuffer &) const {}
297
-
298
289
// Print an initializer list of this type. Returns true if we printed a custom
299
290
// representation, false if nothing has been printed and the default
300
291
// representation should be used.
@@ -310,6 +301,24 @@ class Node {
310
301
#ifndef NDEBUG
311
302
DEMANGLE_DUMP_METHOD void dump () const ;
312
303
#endif
304
+
305
+ private:
306
+ friend class OutputBuffer ;
307
+
308
+ // Print the "left" side of this Node into OutputBuffer.
309
+ //
310
+ // Note, should only be called from OutputBuffer implementations.
311
+ // Call \ref OutputBuffer::printLeft instead.
312
+ virtual void printLeft (OutputBuffer &) const = 0;
313
+
314
+ // Print the "right". This distinction is necessary to represent C++ types
315
+ // that appear on the RHS of their subtype, such as arrays or functions.
316
+ // Since most types don't have such a component, provide a default
317
+ // implementation.
318
+ //
319
+ // Note, should only be called from OutputBuffer implementations.
320
+ // Call \ref OutputBuffer::printRight instead.
321
+ virtual void printRight (OutputBuffer &) const {}
313
322
};
314
323
315
324
class NodeArray {
@@ -458,11 +467,11 @@ class QualType final : public Node {
458
467
}
459
468
460
469
void printLeft (OutputBuffer &OB) const override {
461
- Child-> printLeft (OB );
470
+ OB. printLeft (*Child );
462
471
printQuals (OB);
463
472
}
464
473
465
- void printRight (OutputBuffer &OB) const override { Child-> printRight (OB ); }
474
+ void printRight (OutputBuffer &OB) const override { OB. printRight (*Child ); }
466
475
};
467
476
468
477
class ConversionOperatorType final : public Node {
@@ -491,7 +500,7 @@ class PostfixQualifiedType final : public Node {
491
500
template <typename Fn> void match (Fn F) const { F (Ty, Postfix); }
492
501
493
502
void printLeft (OutputBuffer &OB) const override {
494
- Ty-> printLeft (OB );
503
+ OB. printLeft (*Ty );
495
504
OB += Postfix;
496
505
}
497
506
};
@@ -577,7 +586,7 @@ struct AbiTagAttr : Node {
577
586
std::string_view getBaseName () const override { return Base->getBaseName (); }
578
587
579
588
void printLeft (OutputBuffer &OB) const override {
580
- Base-> printLeft (OB );
589
+ OB. printLeft (*Base );
581
590
OB += " [abi:" ;
582
591
OB += Tag;
583
592
OB += " ]" ;
@@ -644,7 +653,7 @@ class PointerType final : public Node {
644
653
// We rewrite objc_object<SomeProtocol>* into id<SomeProtocol>.
645
654
if (Pointee->getKind () != KObjCProtoName ||
646
655
!static_cast <const ObjCProtoName *>(Pointee)->isObjCObject ()) {
647
- Pointee-> printLeft (OB );
656
+ OB. printLeft (*Pointee );
648
657
if (Pointee->hasArray (OB))
649
658
OB += " " ;
650
659
if (Pointee->hasArray (OB) || Pointee->hasFunction (OB))
@@ -663,7 +672,7 @@ class PointerType final : public Node {
663
672
!static_cast <const ObjCProtoName *>(Pointee)->isObjCObject ()) {
664
673
if (Pointee->hasArray (OB) || Pointee->hasFunction (OB))
665
674
OB += " )" ;
666
- Pointee-> printRight (OB );
675
+ OB. printRight (*Pointee );
667
676
}
668
677
}
669
678
};
@@ -729,7 +738,7 @@ class ReferenceType : public Node {
729
738
std::pair<ReferenceKind, const Node *> Collapsed = collapse (OB);
730
739
if (!Collapsed.second )
731
740
return ;
732
- Collapsed. second -> printLeft (OB );
741
+ OB. printLeft (*Collapsed. second );
733
742
if (Collapsed.second ->hasArray (OB))
734
743
OB += " " ;
735
744
if (Collapsed.second ->hasArray (OB) || Collapsed.second ->hasFunction (OB))
@@ -746,7 +755,7 @@ class ReferenceType : public Node {
746
755
return ;
747
756
if (Collapsed.second ->hasArray (OB) || Collapsed.second ->hasFunction (OB))
748
757
OB += " )" ;
749
- Collapsed. second -> printRight (OB );
758
+ OB. printRight (*Collapsed. second );
750
759
}
751
760
};
752
761
@@ -766,7 +775,7 @@ class PointerToMemberType final : public Node {
766
775
}
767
776
768
777
void printLeft (OutputBuffer &OB) const override {
769
- MemberType-> printLeft (OB );
778
+ OB. printLeft (*MemberType );
770
779
if (MemberType->hasArray (OB) || MemberType->hasFunction (OB))
771
780
OB += " (" ;
772
781
else
@@ -778,7 +787,7 @@ class PointerToMemberType final : public Node {
778
787
void printRight (OutputBuffer &OB) const override {
779
788
if (MemberType->hasArray (OB) || MemberType->hasFunction (OB))
780
789
OB += " )" ;
781
- MemberType-> printRight (OB );
790
+ OB. printRight (*MemberType );
782
791
}
783
792
};
784
793
@@ -798,7 +807,7 @@ class ArrayType final : public Node {
798
807
bool hasRHSComponentSlow (OutputBuffer &) const override { return true ; }
799
808
bool hasArraySlow (OutputBuffer &) const override { return true ; }
800
809
801
- void printLeft (OutputBuffer &OB) const override { Base-> printLeft (OB ); }
810
+ void printLeft (OutputBuffer &OB) const override { OB. printLeft (*Base ); }
802
811
803
812
void printRight (OutputBuffer &OB) const override {
804
813
if (OB.back () != ' ]' )
@@ -807,7 +816,7 @@ class ArrayType final : public Node {
807
816
if (Dimension)
808
817
Dimension->print (OB);
809
818
OB += " ]" ;
810
- Base-> printRight (OB );
819
+ OB. printRight (*Base );
811
820
}
812
821
813
822
bool printInitListAsType (OutputBuffer &OB,
@@ -851,15 +860,15 @@ class FunctionType final : public Node {
851
860
// by printing out the return types's left, then print our parameters, then
852
861
// finally print right of the return type.
853
862
void printLeft (OutputBuffer &OB) const override {
854
- Ret-> printLeft (OB );
863
+ OB. printLeft (*Ret );
855
864
OB += " " ;
856
865
}
857
866
858
867
void printRight (OutputBuffer &OB) const override {
859
868
OB.printOpen ();
860
869
Params.printWithComma (OB);
861
870
OB.printClose ();
862
- Ret-> printRight (OB );
871
+ OB. printRight (*Ret );
863
872
864
873
if (CVQuals & QualConst)
865
874
OB += " const" ;
@@ -964,6 +973,8 @@ class FunctionEncoding final : public Node {
964
973
FunctionRefQual getRefQual () const { return RefQual; }
965
974
NodeArray getParams () const { return Params; }
966
975
const Node *getReturnType () const { return Ret; }
976
+ const Node *getAttrs () const { return Attrs; }
977
+ const Node *getRequires () const { return Requires; }
967
978
968
979
bool hasRHSComponentSlow (OutputBuffer &) const override { return true ; }
969
980
bool hasFunctionSlow (OutputBuffer &) const override { return true ; }
@@ -972,19 +983,21 @@ class FunctionEncoding final : public Node {
972
983
973
984
void printLeft (OutputBuffer &OB) const override {
974
985
if (Ret) {
975
- Ret-> printLeft (OB );
986
+ OB. printLeft (*Ret );
976
987
if (!Ret->hasRHSComponent (OB))
977
988
OB += " " ;
978
989
}
990
+
979
991
Name->print (OB);
980
992
}
981
993
982
994
void printRight (OutputBuffer &OB) const override {
983
995
OB.printOpen ();
984
996
Params.printWithComma (OB);
985
997
OB.printClose ();
998
+
986
999
if (Ret)
987
- Ret-> printRight (OB );
1000
+ OB. printRight (*Ret );
988
1001
989
1002
if (CVQuals & QualConst)
990
1003
OB += " const" ;
@@ -1324,14 +1337,14 @@ class NonTypeTemplateParamDecl final : public Node {
1324
1337
template <typename Fn> void match (Fn F) const { F (Name, Type); }
1325
1338
1326
1339
void printLeft (OutputBuffer &OB) const override {
1327
- Type-> printLeft (OB );
1340
+ OB. printLeft (*Type );
1328
1341
if (!Type->hasRHSComponent (OB))
1329
1342
OB += " " ;
1330
1343
}
1331
1344
1332
1345
void printRight (OutputBuffer &OB) const override {
1333
1346
Name->print (OB);
1334
- Type-> printRight (OB );
1347
+ OB. printRight (*Type );
1335
1348
}
1336
1349
};
1337
1350
@@ -1376,11 +1389,11 @@ class TemplateParamPackDecl final : public Node {
1376
1389
template <typename Fn> void match (Fn F) const { F (Param); }
1377
1390
1378
1391
void printLeft (OutputBuffer &OB) const override {
1379
- Param-> printLeft (OB );
1392
+ OB. printLeft (*Param );
1380
1393
OB += " ..." ;
1381
1394
}
1382
1395
1383
- void printRight (OutputBuffer &OB) const override { Param-> printRight (OB ); }
1396
+ void printRight (OutputBuffer &OB) const override { OB. printRight (*Param ); }
1384
1397
};
1385
1398
1386
1399
// / An unexpanded parameter pack (either in the expression or type context). If
@@ -1445,13 +1458,13 @@ class ParameterPack final : public Node {
1445
1458
initializePackExpansion (OB);
1446
1459
size_t Idx = OB.CurrentPackIndex ;
1447
1460
if (Idx < Data.size ())
1448
- Data[Idx]-> printLeft (OB );
1461
+ OB. printLeft (* Data[Idx]);
1449
1462
}
1450
1463
void printRight (OutputBuffer &OB) const override {
1451
1464
initializePackExpansion (OB);
1452
1465
size_t Idx = OB.CurrentPackIndex ;
1453
1466
if (Idx < Data.size ())
1454
- Data[Idx]-> printRight (OB );
1467
+ OB. printRight (* Data[Idx]);
1455
1468
}
1456
1469
};
1457
1470
@@ -1609,13 +1622,13 @@ struct ForwardTemplateReference : Node {
1609
1622
if (Printing)
1610
1623
return ;
1611
1624
ScopedOverride<bool > SavePrinting (Printing, true );
1612
- Ref-> printLeft (OB );
1625
+ OB. printLeft (*Ref );
1613
1626
}
1614
1627
void printRight (OutputBuffer &OB) const override {
1615
1628
if (Printing)
1616
1629
return ;
1617
1630
ScopedOverride<bool > SavePrinting (Printing, true );
1618
- Ref-> printRight (OB );
1631
+ OB. printRight (*Ref );
1619
1632
}
1620
1633
};
1621
1634
@@ -1767,7 +1780,7 @@ class DtorName : public Node {
1767
1780
1768
1781
void printLeft (OutputBuffer &OB) const override {
1769
1782
OB += " ~" ;
1770
- Base-> printLeft (OB );
1783
+ OB. printLeft (*Base );
1771
1784
}
1772
1785
};
1773
1786
@@ -2047,7 +2060,7 @@ class CastExpr : public Node {
2047
2060
{
2048
2061
ScopedOverride<unsigned > LT (OB.GtIsGt , 0 );
2049
2062
OB += " <" ;
2050
- To-> printLeft (OB );
2063
+ OB. printLeft (*To );
2051
2064
OB += " >" ;
2052
2065
}
2053
2066
OB.printOpen ();
@@ -6176,6 +6189,10 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {
6176
6189
Alloc>::AbstractManglingParser;
6177
6190
};
6178
6191
6192
+ inline void OutputBuffer::printLeft (const Node &N) { N.printLeft (*this ); }
6193
+
6194
+ inline void OutputBuffer::printRight (const Node &N) { N.printRight (*this ); }
6195
+
6179
6196
DEMANGLE_NAMESPACE_END
6180
6197
6181
6198
#if defined(__clang__)
0 commit comments