Skip to content

Commit 46455c5

Browse files
committed
fixup! Add location tracking version of OutputBuffer in LLDB
1 parent 0875195 commit 46455c5

File tree

14 files changed

+589
-625
lines changed

14 files changed

+589
-625
lines changed

libcxxabi/src/demangle/ItaniumDemangle.h

Lines changed: 34 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ class Node {
281281
}
282282

283283
void print(OutputBuffer &OB) const {
284-
printLeft(OB);
284+
OB.printLeft(*this);
285285
if (RHSComponentCache != Cache::No)
286-
printRight(OB);
286+
OB.printRight(*this);
287287
}
288288

289289
// Print the "left" side of this Node into OutputBuffer.
@@ -458,11 +458,11 @@ class QualType final : public Node {
458458
}
459459

460460
void printLeft(OutputBuffer &OB) const override {
461-
Child->printLeft(OB);
461+
OB.printLeft(*Child);
462462
printQuals(OB);
463463
}
464464

465-
void printRight(OutputBuffer &OB) const override { Child->printRight(OB); }
465+
void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); }
466466
};
467467

468468
class ConversionOperatorType final : public Node {
@@ -491,7 +491,7 @@ class PostfixQualifiedType final : public Node {
491491
template<typename Fn> void match(Fn F) const { F(Ty, Postfix); }
492492

493493
void printLeft(OutputBuffer &OB) const override {
494-
Ty->printLeft(OB);
494+
OB.printLeft(*Ty);
495495
OB += Postfix;
496496
}
497497
};
@@ -577,7 +577,7 @@ struct AbiTagAttr : Node {
577577
std::string_view getBaseName() const override { return Base->getBaseName(); }
578578

579579
void printLeft(OutputBuffer &OB) const override {
580-
Base->printLeft(OB);
580+
OB.printLeft(*Base);
581581
OB += "[abi:";
582582
OB += Tag;
583583
OB += "]";
@@ -644,7 +644,7 @@ class PointerType final : public Node {
644644
// We rewrite objc_object<SomeProtocol>* into id<SomeProtocol>.
645645
if (Pointee->getKind() != KObjCProtoName ||
646646
!static_cast<const ObjCProtoName *>(Pointee)->isObjCObject()) {
647-
Pointee->printLeft(OB);
647+
OB.printLeft(*Pointee);
648648
if (Pointee->hasArray(OB))
649649
OB += " ";
650650
if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
@@ -663,7 +663,7 @@ class PointerType final : public Node {
663663
!static_cast<const ObjCProtoName *>(Pointee)->isObjCObject()) {
664664
if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
665665
OB += ")";
666-
Pointee->printRight(OB);
666+
OB.printRight(*Pointee);
667667
}
668668
}
669669
};
@@ -729,7 +729,7 @@ class ReferenceType : public Node {
729729
std::pair<ReferenceKind, const Node *> Collapsed = collapse(OB);
730730
if (!Collapsed.second)
731731
return;
732-
Collapsed.second->printLeft(OB);
732+
OB.printLeft(*Collapsed.second);
733733
if (Collapsed.second->hasArray(OB))
734734
OB += " ";
735735
if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
@@ -746,7 +746,7 @@ class ReferenceType : public Node {
746746
return;
747747
if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
748748
OB += ")";
749-
Collapsed.second->printRight(OB);
749+
OB.printRight(*Collapsed.second);
750750
}
751751
};
752752

@@ -766,7 +766,7 @@ class PointerToMemberType final : public Node {
766766
}
767767

768768
void printLeft(OutputBuffer &OB) const override {
769-
MemberType->printLeft(OB);
769+
OB.printLeft(*MemberType);
770770
if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
771771
OB += "(";
772772
else
@@ -778,7 +778,7 @@ class PointerToMemberType final : public Node {
778778
void printRight(OutputBuffer &OB) const override {
779779
if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
780780
OB += ")";
781-
MemberType->printRight(OB);
781+
OB.printRight(*MemberType);
782782
}
783783
};
784784

@@ -798,7 +798,7 @@ class ArrayType final : public Node {
798798
bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
799799
bool hasArraySlow(OutputBuffer &) const override { return true; }
800800

801-
void printLeft(OutputBuffer &OB) const override { Base->printLeft(OB); }
801+
void printLeft(OutputBuffer &OB) const override { OB.printLeft(*Base); }
802802

803803
void printRight(OutputBuffer &OB) const override {
804804
if (OB.back() != ']')
@@ -807,7 +807,7 @@ class ArrayType final : public Node {
807807
if (Dimension)
808808
Dimension->print(OB);
809809
OB += "]";
810-
Base->printRight(OB);
810+
OB.printRight(*Base);
811811
}
812812

813813
bool printInitListAsType(OutputBuffer &OB,
@@ -851,17 +851,15 @@ class FunctionType final : public Node {
851851
// by printing out the return types's left, then print our parameters, then
852852
// finally print right of the return type.
853853
void printLeft(OutputBuffer &OB) const override {
854-
auto Scoped = OB.enterFunctionTypePrinting();
855-
Ret->printLeft(OB);
854+
OB.printLeft(*Ret);
856855
OB += " ";
857856
}
858857

859858
void printRight(OutputBuffer &OB) const override {
860-
auto Scoped = OB.enterFunctionTypePrinting();
861859
OB.printOpen();
862860
Params.printWithComma(OB);
863861
OB.printClose();
864-
Ret->printRight(OB);
862+
OB.printRight(*Ret);
865863

866864
if (CVQuals & QualConst)
867865
OB += " const";
@@ -966,41 +964,31 @@ class FunctionEncoding final : public Node {
966964
FunctionRefQual getRefQual() const { return RefQual; }
967965
NodeArray getParams() const { return Params; }
968966
const Node *getReturnType() const { return Ret; }
967+
const Node *getAttrs() const { return Attrs; }
968+
const Node *getRequires() const { return Requires; }
969969

970970
bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
971971
bool hasFunctionSlow(OutputBuffer &) const override { return true; }
972972

973973
const Node *getName() const { return Name; }
974974

975975
void printLeft(OutputBuffer &OB) const override {
976-
// Nested FunctionEncoding parsing can happen with following productions:
977-
// * <local-name>
978-
// * <expr-primary>
979-
auto Scoped = OB.enterFunctionTypePrinting();
980-
981976
if (Ret) {
982-
Ret->printLeft(OB);
977+
OB.printLeft(*Ret);
983978
if (!Ret->hasRHSComponent(OB))
984979
OB += " ";
985980
}
986981

987-
OB.FunctionInfo.updateScopeStart(OB);
988-
989982
Name->print(OB);
990983
}
991984

992985
void printRight(OutputBuffer &OB) const override {
993-
auto Scoped = OB.enterFunctionTypePrinting();
994-
OB.FunctionInfo.finalizeStart(OB);
995-
996986
OB.printOpen();
997987
Params.printWithComma(OB);
998988
OB.printClose();
999989

1000-
OB.FunctionInfo.finalizeArgumentEnd(OB);
1001-
1002990
if (Ret)
1003-
Ret->printRight(OB);
991+
OB.printRight(*Ret);
1004992

1005993
if (CVQuals & QualConst)
1006994
OB += " const";
@@ -1021,8 +1009,6 @@ class FunctionEncoding final : public Node {
10211009
OB += " requires ";
10221010
Requires->print(OB);
10231011
}
1024-
1025-
OB.FunctionInfo.finalizeEnd(OB);
10261012
}
10271013
};
10281014

@@ -1090,9 +1076,7 @@ struct NestedName : Node {
10901076
void printLeft(OutputBuffer &OB) const override {
10911077
Qual->print(OB);
10921078
OB += "::";
1093-
OB.FunctionInfo.updateScopeEnd(OB);
10941079
Name->print(OB);
1095-
OB.FunctionInfo.updateBasenameEnd(OB);
10961080
}
10971081
};
10981082

@@ -1344,14 +1328,14 @@ class NonTypeTemplateParamDecl final : public Node {
13441328
template<typename Fn> void match(Fn F) const { F(Name, Type); }
13451329

13461330
void printLeft(OutputBuffer &OB) const override {
1347-
Type->printLeft(OB);
1331+
OB.printLeft(*Type);
13481332
if (!Type->hasRHSComponent(OB))
13491333
OB += " ";
13501334
}
13511335

13521336
void printRight(OutputBuffer &OB) const override {
13531337
Name->print(OB);
1354-
Type->printRight(OB);
1338+
OB.printRight(*Type);
13551339
}
13561340
};
13571341

@@ -1396,11 +1380,11 @@ class TemplateParamPackDecl final : public Node {
13961380
template<typename Fn> void match(Fn F) const { F(Param); }
13971381

13981382
void printLeft(OutputBuffer &OB) const override {
1399-
Param->printLeft(OB);
1383+
OB.printLeft(*Param);
14001384
OB += "...";
14011385
}
14021386

1403-
void printRight(OutputBuffer &OB) const override { Param->printRight(OB); }
1387+
void printRight(OutputBuffer &OB) const override { OB.printRight(*Param); }
14041388
};
14051389

14061390
/// An unexpanded parameter pack (either in the expression or type context). If
@@ -1465,13 +1449,13 @@ class ParameterPack final : public Node {
14651449
initializePackExpansion(OB);
14661450
size_t Idx = OB.CurrentPackIndex;
14671451
if (Idx < Data.size())
1468-
Data[Idx]->printLeft(OB);
1452+
OB.printLeft(*Data[Idx]);
14691453
}
14701454
void printRight(OutputBuffer &OB) const override {
14711455
initializePackExpansion(OB);
14721456
size_t Idx = OB.CurrentPackIndex;
14731457
if (Idx < Data.size())
1474-
Data[Idx]->printRight(OB);
1458+
OB.printRight(*Data[Idx]);
14751459
}
14761460
};
14771461

@@ -1629,13 +1613,13 @@ struct ForwardTemplateReference : Node {
16291613
if (Printing)
16301614
return;
16311615
ScopedOverride<bool> SavePrinting(Printing, true);
1632-
Ref->printLeft(OB);
1616+
OB.printLeft(*Ref);
16331617
}
16341618
void printRight(OutputBuffer &OB) const override {
16351619
if (Printing)
16361620
return;
16371621
ScopedOverride<bool> SavePrinting(Printing, true);
1638-
Ref->printRight(OB);
1622+
OB.printRight(*Ref);
16391623
}
16401624
};
16411625

@@ -1653,7 +1637,6 @@ struct NameWithTemplateArgs : Node {
16531637

16541638
void printLeft(OutputBuffer &OB) const override {
16551639
Name->print(OB);
1656-
OB.FunctionInfo.updateBasenameEnd(OB);
16571640
TemplateArgs->print(OB);
16581641
}
16591642
};
@@ -1788,7 +1771,7 @@ class DtorName : public Node {
17881771

17891772
void printLeft(OutputBuffer &OB) const override {
17901773
OB += "~";
1791-
Base->printLeft(OB);
1774+
OB.printLeft(*Base);
17921775
}
17931776
};
17941777

@@ -2068,7 +2051,7 @@ class CastExpr : public Node {
20682051
{
20692052
ScopedOverride<unsigned> LT(OB.GtIsGt, 0);
20702053
OB += "<";
2071-
To->printLeft(OB);
2054+
OB.printLeft(*To);
20722055
OB += ">";
20732056
}
20742057
OB.printOpen();
@@ -6197,6 +6180,10 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {
61976180
Alloc>::AbstractManglingParser;
61986181
};
61996182

6183+
inline void OutputBuffer::printLeft(const Node &N) { N.printLeft(*this); }
6184+
6185+
inline void OutputBuffer::printRight(const Node &N) { N.printRight(*this); }
6186+
62006187
DEMANGLE_NAMESPACE_END
62016188

62026189
#if defined(__clang__)

0 commit comments

Comments
 (0)