@@ -278,20 +278,11 @@ 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 {}
294
-
295
286
virtual std::string_view getBaseName () const { return {}; }
296
287
297
288
// Silence compiler warnings, this dtor will never be called.
@@ -300,6 +291,24 @@ class Node {
300
291
#ifndef NDEBUG
301
292
DEMANGLE_DUMP_METHOD void dump () const ;
302
293
#endif
294
+
295
+ private:
296
+ friend class OutputBuffer ;
297
+
298
+ // Print the "left" side of this Node into OutputBuffer.
299
+ //
300
+ // Note, should only be called from OutputBuffer implementations.
301
+ // Call \ref OutputBuffer::printLeft instead.
302
+ virtual void printLeft (OutputBuffer &) const = 0;
303
+
304
+ // Print the "right". This distinction is necessary to represent C++ types
305
+ // that appear on the RHS of their subtype, such as arrays or functions.
306
+ // Since most types don't have such a component, provide a default
307
+ // implementation.
308
+ //
309
+ // Note, should only be called from OutputBuffer implementations.
310
+ // Call \ref OutputBuffer::printRight instead.
311
+ virtual void printRight (OutputBuffer &) const {}
303
312
};
304
313
305
314
class NodeArray {
@@ -444,11 +453,11 @@ class QualType final : public Node {
444
453
}
445
454
446
455
void printLeft (OutputBuffer &OB) const override {
447
- Child-> printLeft (OB );
456
+ OB. printLeft (*Child );
448
457
printQuals (OB);
449
458
}
450
459
451
- void printRight (OutputBuffer &OB) const override { Child-> printRight (OB ); }
460
+ void printRight (OutputBuffer &OB) const override { OB. printRight (*Child ); }
452
461
};
453
462
454
463
class ConversionOperatorType final : public Node {
@@ -477,7 +486,7 @@ class PostfixQualifiedType final : public Node {
477
486
template <typename Fn> void match (Fn F) const { F (Ty, Postfix); }
478
487
479
488
void printLeft (OutputBuffer &OB) const override {
480
- Ty-> printLeft (OB );
489
+ OB. printLeft (*Ty );
481
490
OB += Postfix;
482
491
}
483
492
};
@@ -563,7 +572,7 @@ struct AbiTagAttr : Node {
563
572
std::string_view getBaseName () const override { return Base->getBaseName (); }
564
573
565
574
void printLeft (OutputBuffer &OB) const override {
566
- Base-> printLeft (OB );
575
+ OB. printLeft (*Base );
567
576
OB += " [abi:" ;
568
577
OB += Tag;
569
578
OB += " ]" ;
@@ -630,7 +639,7 @@ class PointerType final : public Node {
630
639
// We rewrite objc_object<SomeProtocol>* into id<SomeProtocol>.
631
640
if (Pointee->getKind () != KObjCProtoName ||
632
641
!static_cast <const ObjCProtoName *>(Pointee)->isObjCObject ()) {
633
- Pointee-> printLeft (OB );
642
+ OB. printLeft (*Pointee );
634
643
if (Pointee->hasArray (OB))
635
644
OB += " " ;
636
645
if (Pointee->hasArray (OB) || Pointee->hasFunction (OB))
@@ -649,7 +658,7 @@ class PointerType final : public Node {
649
658
!static_cast <const ObjCProtoName *>(Pointee)->isObjCObject ()) {
650
659
if (Pointee->hasArray (OB) || Pointee->hasFunction (OB))
651
660
OB += " )" ;
652
- Pointee-> printRight (OB );
661
+ OB. printRight (*Pointee );
653
662
}
654
663
}
655
664
};
@@ -715,7 +724,7 @@ class ReferenceType : public Node {
715
724
std::pair<ReferenceKind, const Node *> Collapsed = collapse (OB);
716
725
if (!Collapsed.second )
717
726
return ;
718
- Collapsed. second -> printLeft (OB );
727
+ OB. printLeft (*Collapsed. second );
719
728
if (Collapsed.second ->hasArray (OB))
720
729
OB += " " ;
721
730
if (Collapsed.second ->hasArray (OB) || Collapsed.second ->hasFunction (OB))
@@ -732,7 +741,7 @@ class ReferenceType : public Node {
732
741
return ;
733
742
if (Collapsed.second ->hasArray (OB) || Collapsed.second ->hasFunction (OB))
734
743
OB += " )" ;
735
- Collapsed. second -> printRight (OB );
744
+ OB. printRight (*Collapsed. second );
736
745
}
737
746
};
738
747
@@ -752,7 +761,7 @@ class PointerToMemberType final : public Node {
752
761
}
753
762
754
763
void printLeft (OutputBuffer &OB) const override {
755
- MemberType-> printLeft (OB );
764
+ OB. printLeft (*MemberType );
756
765
if (MemberType->hasArray (OB) || MemberType->hasFunction (OB))
757
766
OB += " (" ;
758
767
else
@@ -764,7 +773,7 @@ class PointerToMemberType final : public Node {
764
773
void printRight (OutputBuffer &OB) const override {
765
774
if (MemberType->hasArray (OB) || MemberType->hasFunction (OB))
766
775
OB += " )" ;
767
- MemberType-> printRight (OB );
776
+ OB. printRight (*MemberType );
768
777
}
769
778
};
770
779
@@ -784,7 +793,7 @@ class ArrayType final : public Node {
784
793
bool hasRHSComponentSlow (OutputBuffer &) const override { return true ; }
785
794
bool hasArraySlow (OutputBuffer &) const override { return true ; }
786
795
787
- void printLeft (OutputBuffer &OB) const override { Base-> printLeft (OB ); }
796
+ void printLeft (OutputBuffer &OB) const override { OB. printLeft (*Base ); }
788
797
789
798
void printRight (OutputBuffer &OB) const override {
790
799
if (OB.back () != ' ]' )
@@ -793,7 +802,7 @@ class ArrayType final : public Node {
793
802
if (Dimension)
794
803
Dimension->print (OB);
795
804
OB += " ]" ;
796
- Base-> printRight (OB );
805
+ OB. printRight (*Base );
797
806
}
798
807
};
799
808
@@ -828,15 +837,15 @@ class FunctionType final : public Node {
828
837
// by printing out the return types's left, then print our parameters, then
829
838
// finally print right of the return type.
830
839
void printLeft (OutputBuffer &OB) const override {
831
- Ret-> printLeft (OB );
840
+ OB. printLeft (*Ret );
832
841
OB += " " ;
833
842
}
834
843
835
844
void printRight (OutputBuffer &OB) const override {
836
845
OB.printOpen ();
837
846
Params.printWithComma (OB);
838
847
OB.printClose ();
839
- Ret-> printRight (OB );
848
+ OB. printRight (*Ret );
840
849
841
850
if (CVQuals & QualConst)
842
851
OB += " const" ;
@@ -941,6 +950,8 @@ class FunctionEncoding final : public Node {
941
950
FunctionRefQual getRefQual () const { return RefQual; }
942
951
NodeArray getParams () const { return Params; }
943
952
const Node *getReturnType () const { return Ret; }
953
+ const Node *getAttrs () const { return Attrs; }
954
+ const Node *getRequires () const { return Requires; }
944
955
945
956
bool hasRHSComponentSlow (OutputBuffer &) const override { return true ; }
946
957
bool hasFunctionSlow (OutputBuffer &) const override { return true ; }
@@ -949,19 +960,21 @@ class FunctionEncoding final : public Node {
949
960
950
961
void printLeft (OutputBuffer &OB) const override {
951
962
if (Ret) {
952
- Ret-> printLeft (OB );
963
+ OB. printLeft (*Ret );
953
964
if (!Ret->hasRHSComponent (OB))
954
965
OB += " " ;
955
966
}
967
+
956
968
Name->print (OB);
957
969
}
958
970
959
971
void printRight (OutputBuffer &OB) const override {
960
972
OB.printOpen ();
961
973
Params.printWithComma (OB);
962
974
OB.printClose ();
975
+
963
976
if (Ret)
964
- Ret-> printRight (OB );
977
+ OB. printRight (*Ret );
965
978
966
979
if (CVQuals & QualConst)
967
980
OB += " const" ;
@@ -1301,14 +1314,14 @@ class NonTypeTemplateParamDecl final : public Node {
1301
1314
template <typename Fn> void match (Fn F) const { F (Name, Type); }
1302
1315
1303
1316
void printLeft (OutputBuffer &OB) const override {
1304
- Type-> printLeft (OB );
1317
+ OB. printLeft (*Type );
1305
1318
if (!Type->hasRHSComponent (OB))
1306
1319
OB += " " ;
1307
1320
}
1308
1321
1309
1322
void printRight (OutputBuffer &OB) const override {
1310
1323
Name->print (OB);
1311
- Type-> printRight (OB );
1324
+ OB. printRight (*Type );
1312
1325
}
1313
1326
};
1314
1327
@@ -1353,11 +1366,11 @@ class TemplateParamPackDecl final : public Node {
1353
1366
template <typename Fn> void match (Fn F) const { F (Param); }
1354
1367
1355
1368
void printLeft (OutputBuffer &OB) const override {
1356
- Param-> printLeft (OB );
1369
+ OB. printLeft (*Param );
1357
1370
OB += " ..." ;
1358
1371
}
1359
1372
1360
- void printRight (OutputBuffer &OB) const override { Param-> printRight (OB ); }
1373
+ void printRight (OutputBuffer &OB) const override { OB. printRight (*Param ); }
1361
1374
};
1362
1375
1363
1376
// / An unexpanded parameter pack (either in the expression or type context). If
@@ -1424,13 +1437,13 @@ class ParameterPack final : public Node {
1424
1437
initializePackExpansion (OB);
1425
1438
size_t Idx = OB.CurrentPackIndex ;
1426
1439
if (Idx < Data.size ())
1427
- Data[Idx]-> printLeft (OB );
1440
+ OB. printLeft (* Data[Idx]);
1428
1441
}
1429
1442
void printRight (OutputBuffer &OB) const override {
1430
1443
initializePackExpansion (OB);
1431
1444
size_t Idx = OB.CurrentPackIndex ;
1432
1445
if (Idx < Data.size ())
1433
- Data[Idx]-> printRight (OB );
1446
+ OB. printRight (* Data[Idx]);
1434
1447
}
1435
1448
};
1436
1449
@@ -1588,13 +1601,13 @@ struct ForwardTemplateReference : Node {
1588
1601
if (Printing)
1589
1602
return ;
1590
1603
ScopedOverride<bool > SavePrinting (Printing, true );
1591
- Ref-> printLeft (OB );
1604
+ OB. printLeft (*Ref );
1592
1605
}
1593
1606
void printRight (OutputBuffer &OB) const override {
1594
1607
if (Printing)
1595
1608
return ;
1596
1609
ScopedOverride<bool > SavePrinting (Printing, true );
1597
- Ref-> printRight (OB );
1610
+ OB. printRight (*Ref );
1598
1611
}
1599
1612
};
1600
1613
@@ -1746,7 +1759,7 @@ class DtorName : public Node {
1746
1759
1747
1760
void printLeft (OutputBuffer &OB) const override {
1748
1761
OB += " ~" ;
1749
- Base-> printLeft (OB );
1762
+ OB. printLeft (*Base );
1750
1763
}
1751
1764
};
1752
1765
@@ -2026,7 +2039,7 @@ class CastExpr : public Node {
2026
2039
{
2027
2040
ScopedOverride<unsigned > LT (OB.GtIsGt , 0 );
2028
2041
OB += " <" ;
2029
- To-> printLeft (OB );
2042
+ OB. printLeft (*To );
2030
2043
OB += " >" ;
2031
2044
}
2032
2045
OB.printOpen ();
@@ -5946,6 +5959,10 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {
5946
5959
Alloc>::AbstractManglingParser;
5947
5960
};
5948
5961
5962
+ inline void OutputBuffer::printLeft (const Node &N) { N.printLeft (*this ); }
5963
+
5964
+ inline void OutputBuffer::printRight (const Node &N) { N.printRight (*this ); }
5965
+
5949
5966
DEMANGLE_NAMESPACE_END
5950
5967
5951
5968
#ifdef _LIBCXXABI_COMPILER_CLANG
0 commit comments