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