1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[demangler] Tweak how parameter pack sizes are determined.

Rather than eagerly propagating up parameter pack sizes in Node ctors,
find the parameter pack size during printing. This is being done to
support back-patching forward referencing <template-param>s.

llvm-svn: 328463
This commit is contained in:
Erik Pilkington 2018-03-25 22:49:57 +00:00
parent 1043b33b88
commit f962a81231

View File

@ -101,6 +101,7 @@ public:
/// If a ParameterPackExpansion (or similar type) is encountered, the offset
/// into the pack that we're currently printing.
unsigned CurrentPackIndex = std::numeric_limits<unsigned>::max();
unsigned CurrentPackMax = std::numeric_limits<unsigned>::max();
OutputStream &operator+=(StringView R) {
size_t Size = R.size();
@ -118,7 +119,8 @@ public:
return *this;
}
size_t getCurrentPosition() const { return CurrentPosition; };
size_t getCurrentPosition() const { return CurrentPosition; }
void setCurrentPosition(size_t NewPos) { CurrentPosition = NewPos; }
char back() const {
return CurrentPosition ? Buffer[CurrentPosition - 1] : '\0';
@ -195,10 +197,6 @@ public:
KBracedRangeExpr,
};
static constexpr unsigned NoParameterPack =
std::numeric_limits<unsigned>::max();
unsigned ParameterPackSize = NoParameterPack;
Kind K;
/// Three-way bool to track a cached value. Unknown is possible if this node
@ -217,17 +215,11 @@ public:
/// affect how we format the output string.
Cache FunctionCache;
Node(Kind K_, unsigned ParameterPackSize_ = NoParameterPack,
Cache RHSComponentCache_ = Cache::No, Cache ArrayCache_ = Cache::No,
Cache FunctionCache_ = Cache::No)
: ParameterPackSize(ParameterPackSize_), K(K_),
RHSComponentCache(RHSComponentCache_), ArrayCache(ArrayCache_),
Node(Kind K_, Cache RHSComponentCache_ = Cache::No,
Cache ArrayCache_ = Cache::No, Cache FunctionCache_ = Cache::No)
: K(K_), RHSComponentCache(RHSComponentCache_), ArrayCache(ArrayCache_),
FunctionCache(FunctionCache_) {}
bool containsUnexpandedParameterPack() const {
return ParameterPackSize != NoParameterPack;
}
bool hasRHSComponent(OutputStream &S) const {
if (RHSComponentCache != Cache::Unknown)
return RHSComponentCache == Cache::Yes;
@ -252,10 +244,6 @@ public:
virtual bool hasArraySlow(OutputStream &) const { return false; }
virtual bool hasFunctionSlow(OutputStream &) const { return false; }
/// If this node is a pack expansion that expands to 0 elements. This can have
/// an effect on how we should format the output.
bool isEmptyPackExpansion() const;
void print(OutputStream &S) const {
printLeft(S);
if (RHSComponentCache != Cache::No)
@ -308,12 +296,20 @@ public:
void printWithComma(OutputStream &S) const {
bool FirstElement = true;
for (size_t Idx = 0; Idx != NumElements; ++Idx) {
if (Elements[Idx]->isEmptyPackExpansion())
continue;
size_t BeforeComma = S.getCurrentPosition();
if (!FirstElement)
S += ", ";
FirstElement = false;
size_t AfterComma = S.getCurrentPosition();
Elements[Idx]->print(S);
// Elements[Idx] is an empty parameter pack expansion, we should erase the
// comma we just printed.
if (AfterComma == S.getCurrentPosition()) {
S.setCurrentPosition(BeforeComma);
continue;
}
FirstElement = false;
}
}
};
@ -340,8 +336,7 @@ class VendorExtQualType final : public Node {
public:
VendorExtQualType(Node *Ty_, StringView Ext_)
: Node(KVendorExtQualType, Ty_->ParameterPackSize),
Ty(Ty_), Ext(Ext_) {}
: Node(KVendorExtQualType), Ty(Ty_), Ext(Ext_) {}
void printLeft(OutputStream &S) const override {
Ty->print(S);
@ -383,7 +378,7 @@ protected:
public:
QualType(Node *Child_, Qualifiers Quals_)
: Node(KQualType, Child_->ParameterPackSize, Child_->RHSComponentCache,
: Node(KQualType, Child_->RHSComponentCache,
Child_->ArrayCache, Child_->FunctionCache),
Quals(Quals_), Child(Child_) {}
@ -410,7 +405,7 @@ class ConversionOperatorType final : public Node {
public:
ConversionOperatorType(Node *Ty_)
: Node(KConversionOperatorType, Ty_->ParameterPackSize), Ty(Ty_) {}
: Node(KConversionOperatorType), Ty(Ty_) {}
void printLeft(OutputStream &S) const override {
S += "operator ";
@ -424,8 +419,7 @@ class PostfixQualifiedType final : public Node {
public:
PostfixQualifiedType(Node *Ty_, StringView Postfix_)
: Node(KPostfixQualifiedType, Ty_->ParameterPackSize),
Ty(Ty_), Postfix(Postfix_) {}
: Node(KPostfixQualifiedType), Ty(Ty_), Postfix(Postfix_) {}
void printLeft(OutputStream &s) const override {
Ty->printLeft(s);
@ -450,9 +444,7 @@ class ElaboratedTypeSpefType : public Node {
Node *Child;
public:
ElaboratedTypeSpefType(StringView Kind_, Node *Child_)
: Node(KElaboratedTypeSpefType), Kind(Kind_), Child(Child_) {
ParameterPackSize = Child->ParameterPackSize;
}
: Node(KElaboratedTypeSpefType), Kind(Kind_), Child(Child_) {}
void printLeft(OutputStream &S) const override {
S += Kind;
@ -466,7 +458,7 @@ class AbiTagAttr final : public Node {
StringView Tag;
public:
AbiTagAttr(const Node* Base_, StringView Tag_)
: Node(KAbiTagAttr, Base_->ParameterPackSize, Base_->RHSComponentCache,
: Node(KAbiTagAttr, Base_->RHSComponentCache,
Base_->ArrayCache, Base_->FunctionCache),
Base(Base_), Tag(Tag_) {}
@ -519,8 +511,7 @@ class PointerType final : public Node {
public:
PointerType(Node *Pointee_)
: Node(KPointerType, Pointee_->ParameterPackSize,
Pointee_->RHSComponentCache),
: Node(KPointerType, Pointee_->RHSComponentCache),
Pointee(Pointee_) {}
bool hasRHSComponentSlow(OutputStream &S) const override {
@ -560,8 +551,7 @@ class LValueReferenceType final : public Node {
public:
LValueReferenceType(Node *Pointee_)
: Node(KLValueReferenceType, Pointee_->ParameterPackSize,
Pointee_->RHSComponentCache),
: Node(KLValueReferenceType, Pointee_->RHSComponentCache),
Pointee(Pointee_) {}
bool hasRHSComponentSlow(OutputStream &S) const override {
@ -589,8 +579,7 @@ class RValueReferenceType final : public Node {
public:
RValueReferenceType(Node *Pointee_)
: Node(KRValueReferenceType, Pointee_->ParameterPackSize,
Pointee_->RHSComponentCache),
: Node(KRValueReferenceType, Pointee_->RHSComponentCache),
Pointee(Pointee_) {}
bool hasRHSComponentSlow(OutputStream &S) const override {
@ -620,10 +609,7 @@ class PointerToMemberType final : public Node {
public:
PointerToMemberType(Node *ClassType_, Node *MemberType_)
: Node(KPointerToMemberType,
std::min(MemberType_->ParameterPackSize,
ClassType_->ParameterPackSize),
MemberType_->RHSComponentCache),
: Node(KPointerToMemberType, MemberType_->RHSComponentCache),
ClassType(ClassType_), MemberType(MemberType_) {}
bool hasRHSComponentSlow(OutputStream &S) const override {
@ -689,18 +675,14 @@ class ArrayType final : public Node {
public:
ArrayType(Node *Base_, NodeOrString Dimension_)
: Node(KArrayType, Base_->ParameterPackSize,
: Node(KArrayType,
/*RHSComponentCache=*/Cache::Yes,
/*ArrayCache=*/Cache::Yes),
Base(Base_), Dimension(Dimension_) {
if (Dimension.isNode())
ParameterPackSize =
std::min(ParameterPackSize, Dimension.asNode()->ParameterPackSize);
}
Base(Base_), Dimension(Dimension_) {}
// Incomplete array type.
ArrayType(Node *Base_)
: Node(KArrayType, Base_->ParameterPackSize,
: Node(KArrayType,
/*RHSComponentCache=*/Cache::Yes,
/*ArrayCache=*/Cache::Yes),
Base(Base_) {}
@ -733,17 +715,11 @@ class FunctionType final : public Node {
public:
FunctionType(Node *Ret_, NodeArray Params_, Qualifiers CVQuals_,
FunctionRefQual RefQual_, Node *ExceptionSpec_)
: Node(KFunctionType, Ret_->ParameterPackSize,
: Node(KFunctionType,
/*RHSComponentCache=*/Cache::Yes, /*ArrayCache=*/Cache::No,
/*FunctionCache=*/Cache::Yes),
Ret(Ret_), Params(Params_), CVQuals(CVQuals_), RefQual(RefQual_),
ExceptionSpec(ExceptionSpec_) {
for (Node *P : Params)
ParameterPackSize = std::min(ParameterPackSize, P->ParameterPackSize);
if (ExceptionSpec != nullptr)
ParameterPackSize =
std::min(ParameterPackSize, ExceptionSpec->ParameterPackSize);
}
ExceptionSpec(ExceptionSpec_) {}
bool hasRHSComponentSlow(OutputStream &) const override { return true; }
bool hasFunctionSlow(OutputStream &) const override { return true; }
@ -788,7 +764,7 @@ public:
class NoexceptSpec : public Node {
Node *E;
public:
NoexceptSpec(Node *E_) : Node(KNoexceptSpec, E_->ParameterPackSize), E(E_) {}
NoexceptSpec(Node *E_) : Node(KNoexceptSpec), E(E_) {}
void printLeft(OutputStream &S) const override {
S += "noexcept(";
@ -801,10 +777,7 @@ class DynamicExceptionSpec : public Node {
NodeArray Types;
public:
DynamicExceptionSpec(NodeArray Types_)
: Node(KDynamicExceptionSpec), Types(Types_) {
for (Node *T : Types)
ParameterPackSize = std::min(ParameterPackSize, T->ParameterPackSize);
}
: Node(KDynamicExceptionSpec), Types(Types_) {}
void printLeft(OutputStream &S) const override {
S += "throw(";
@ -824,16 +797,11 @@ class FunctionEncoding final : public Node {
public:
FunctionEncoding(Node *Ret_, Node *Name_, NodeArray Params_,
Node *Attrs_, Qualifiers CVQuals_, FunctionRefQual RefQual_)
: Node(KFunctionEncoding, NoParameterPack,
: Node(KFunctionEncoding,
/*RHSComponentCache=*/Cache::Yes, /*ArrayCache=*/Cache::No,
/*FunctionCache=*/Cache::Yes),
Ret(Ret_), Name(Name_), Params(Params_), Attrs(Attrs_),
CVQuals(CVQuals_), RefQual(RefQual_) {
for (Node *P : Params)
ParameterPackSize = std::min(ParameterPackSize, P->ParameterPackSize);
if (Ret)
ParameterPackSize = std::min(ParameterPackSize, Ret->ParameterPackSize);
}
CVQuals(CVQuals_), RefQual(RefQual_) {}
bool hasRHSComponentSlow(OutputStream &) const override { return true; }
bool hasFunctionSlow(OutputStream &) const override { return true; }
@ -877,8 +845,7 @@ class LiteralOperator : public Node {
const Node *OpName;
public:
LiteralOperator(Node *OpName_)
: Node(KLiteralOperator, OpName_->ParameterPackSize), OpName(OpName_) {}
LiteralOperator(Node *OpName_) : Node(KLiteralOperator), OpName(OpName_) {}
void printLeft(OutputStream &S) const override {
S += "operator\"\" ";
@ -892,8 +859,7 @@ class SpecialName final : public Node {
public:
SpecialName(StringView Special_, Node* Child_)
: Node(KSpecialName, Child_->ParameterPackSize), Special(Special_),
Child(Child_) {}
: Node(KSpecialName), Special(Special_), Child(Child_) {}
void printLeft(OutputStream &S) const override {
S += Special;
@ -907,8 +873,7 @@ class CtorVtableSpecialName final : public Node {
public:
CtorVtableSpecialName(Node *FirstType_, Node *SecondType_)
: Node(KCtorVtableSpecialName, std::min(FirstType_->ParameterPackSize,
SecondType_->ParameterPackSize)),
: Node(KCtorVtableSpecialName),
FirstType(FirstType_), SecondType(SecondType_) {}
void printLeft(OutputStream &S) const override {
@ -926,9 +891,7 @@ class QualifiedName final : public Node {
public:
QualifiedName(Node* Qualifier_, Node* Name_)
: Node(KQualifiedName,
std::min(Qualifier_->ParameterPackSize, Name_->ParameterPackSize)),
Qualifier(Qualifier_), Name(Name_) {}
: Node(KQualifiedName), Qualifier(Qualifier_), Name(Name_) {}
StringView getBaseName() const override { return Name->getBaseName(); }
@ -953,17 +916,10 @@ class VectorType final : public Node {
public:
VectorType(NodeOrString Dimension_)
: Node(KVectorType), BaseType(nullptr), Dimension(Dimension_),
IsPixel(true) {
if (Dimension.isNode())
ParameterPackSize = Dimension.asNode()->ParameterPackSize;
}
IsPixel(true) {}
VectorType(Node *BaseType_, NodeOrString Dimension_)
: Node(KVectorType, BaseType_->ParameterPackSize), BaseType(BaseType_),
Dimension(Dimension_), IsPixel(false) {
if (Dimension.isNode())
ParameterPackSize =
std::min(ParameterPackSize, Dimension.asNode()->ParameterPackSize);
}
: Node(KVectorType), BaseType(BaseType_),
Dimension(Dimension_), IsPixel(false) {}
void printLeft(OutputStream &S) const override {
if (IsPixel) {
@ -992,9 +948,17 @@ public:
/// T_).
class ParameterPack final : public Node {
NodeArray Data;
// Setup OutputStream for a pack expansion unless we're already expanding one.
void initializePackExpansion(OutputStream &S) const {
if (S.CurrentPackMax == std::numeric_limits<unsigned>::max()) {
S.CurrentPackMax = static_cast<unsigned>(Data.size());
S.CurrentPackIndex = 0;
}
}
public:
ParameterPack(NodeArray Data_)
: Node(KParameterPack, static_cast<unsigned>(Data_.size())), Data(Data_) {
ParameterPack(NodeArray Data_) : Node(KParameterPack), Data(Data_) {
ArrayCache = FunctionCache = RHSComponentCache = Cache::Unknown;
if (std::all_of(Data.begin(), Data.end(), [](Node* P) {
return P->ArrayCache == Cache::No;
@ -1011,24 +975,29 @@ public:
}
bool hasRHSComponentSlow(OutputStream &S) const override {
initializePackExpansion(S);
size_t Idx = S.CurrentPackIndex;
return Idx < Data.size() && Data[Idx]->hasRHSComponent(S);
}
bool hasArraySlow(OutputStream &S) const override {
initializePackExpansion(S);
size_t Idx = S.CurrentPackIndex;
return Idx < Data.size() && Data[Idx]->hasArray(S);
}
bool hasFunctionSlow(OutputStream &S) const override {
initializePackExpansion(S);
size_t Idx = S.CurrentPackIndex;
return Idx < Data.size() && Data[Idx]->hasFunction(S);
}
void printLeft(OutputStream &S) const override {
initializePackExpansion(S);
size_t Idx = S.CurrentPackIndex;
if (Idx < Data.size())
Data[Idx]->printLeft(S);
}
void printRight(OutputStream &S) const override {
initializePackExpansion(S);
size_t Idx = S.CurrentPackIndex;
if (Idx < Data.size())
Data[Idx]->printRight(S);
@ -1044,10 +1013,7 @@ class TemplateArgumentPack final : public Node {
NodeArray Elements;
public:
TemplateArgumentPack(NodeArray Elements_)
: Node(KTemplateArgumentPack), Elements(Elements_) {
for (Node *E : Elements)
ParameterPackSize = std::min(E->ParameterPackSize, ParameterPackSize);
}
: Node(KTemplateArgumentPack), Elements(Elements_) {}
NodeArray getElements() const { return Elements; }
@ -1068,16 +1034,31 @@ public:
const Node *getChild() const { return Child; }
void printLeft(OutputStream &S) const override {
unsigned PackSize = Child->ParameterPackSize;
if (PackSize == NoParameterPack) {
constexpr unsigned Max = std::numeric_limits<unsigned>::max();
SwapAndRestore<unsigned> SavePackIdx(S.CurrentPackIndex, Max);
SwapAndRestore<unsigned> SavePackMax(S.CurrentPackMax, Max);
size_t StreamPos = S.getCurrentPosition();
// Print the first element in the pack. If Child contains a ParameterPack,
// it will set up S.CurrentPackMax and print the first element.
Child->print(S);
// No ParameterPack was found in Child. This can occur if we've found a pack
// expansion on a <function-param>.
if (S.CurrentPackMax == Max) {
S += "...";
return;
}
SwapAndRestore<unsigned> SavePackIndex(S.CurrentPackIndex, 0);
for (unsigned I = 0; I != PackSize; ++I) {
if (I != 0)
// We found a ParameterPack, but it has no elements. Erase whatever we may
// of printed.
if (S.CurrentPackMax == 0) {
S.setCurrentPosition(StreamPos);
return;
}
// Else, iterate through the rest of the elements in the pack.
for (unsigned I = 1, E = S.CurrentPackMax; I < E; ++I) {
S += ", ";
S.CurrentPackIndex = I;
Child->print(S);
@ -1085,43 +1066,17 @@ public:
}
};
inline bool Node::isEmptyPackExpansion() const {
if (getKind() == KParameterPackExpansion) {
auto *AsPack = static_cast<const ParameterPackExpansion *>(this);
return AsPack->getChild()->isEmptyPackExpansion();
}
if (getKind() == KTemplateArgumentPack) {
auto *AsTemplateArg = static_cast<const TemplateArgumentPack *>(this);
for (Node *E : AsTemplateArg->getElements())
if (!E->isEmptyPackExpansion())
return false;
return true;
}
return ParameterPackSize == 0;
}
class TemplateArgs final : public Node {
NodeArray Params;
public:
TemplateArgs(NodeArray Params_) : Node(KTemplateArgs), Params(Params_) {
for (Node *P : Params)
ParameterPackSize = std::min(ParameterPackSize, P->ParameterPackSize);
}
TemplateArgs(NodeArray Params_) : Node(KTemplateArgs), Params(Params_) {}
NodeArray getParams() { return Params; }
void printLeft(OutputStream &S) const override {
S += "<";
bool FirstElement = true;
for (size_t Idx = 0, E = Params.size(); Idx != E; ++Idx) {
if (Params[Idx]->isEmptyPackExpansion())
continue;
if (!FirstElement)
S += ", ";
FirstElement = false;
Params[Idx]->print(S);
}
Params.printWithComma(S);
if (S.back() == '>')
S += " ";
S += ">";
@ -1135,9 +1090,7 @@ class NameWithTemplateArgs final : public Node {
public:
NameWithTemplateArgs(Node *Name_, Node *TemplateArgs_)
: Node(KNameWithTemplateArgs, std::min(Name_->ParameterPackSize,
TemplateArgs_->ParameterPackSize)),
Name(Name_), TemplateArgs(TemplateArgs_) {}
: Node(KNameWithTemplateArgs), Name(Name_), TemplateArgs(TemplateArgs_) {}
StringView getBaseName() const override { return Name->getBaseName(); }
@ -1152,7 +1105,7 @@ class GlobalQualifiedName final : public Node {
public:
GlobalQualifiedName(Node* Child_)
: Node(KGlobalQualifiedName, Child_->ParameterPackSize), Child(Child_) {}
: Node(KGlobalQualifiedName), Child(Child_) {}
StringView getBaseName() const override { return Child->getBaseName(); }
@ -1166,8 +1119,7 @@ class StdQualifiedName final : public Node {
Node *Child;
public:
StdQualifiedName(Node *Child_)
: Node(KStdQualifiedName, Child_->ParameterPackSize), Child(Child_) {}
StdQualifiedName(Node *Child_) : Node(KStdQualifiedName), Child(Child_) {}
StringView getBaseName() const override { return Child->getBaseName(); }
@ -1290,8 +1242,7 @@ class CtorDtorName final : public Node {
public:
CtorDtorName(Node *Basename_, bool IsDtor_)
: Node(KCtorDtorName, Basename_->ParameterPackSize),
Basename(Basename_), IsDtor(IsDtor_) {}
: Node(KCtorDtorName), Basename(Basename_), IsDtor(IsDtor_) {}
void printLeft(OutputStream &S) const override {
if (IsDtor)
@ -1304,9 +1255,7 @@ class DtorName : public Node {
const Node *Base;
public:
DtorName(Node *Base_) : Node(KDtorName), Base(Base_) {
ParameterPackSize = Base->ParameterPackSize;
}
DtorName(Node *Base_) : Node(KDtorName), Base(Base_) {}
void printLeft(OutputStream &S) const override {
S += "~";
@ -1333,10 +1282,7 @@ class ClosureTypeName : public Node {
public:
ClosureTypeName(NodeArray Params_, StringView Count_)
: Node(KClosureTypeName), Params(Params_), Count(Count_) {
for (Node *P : Params)
ParameterPackSize = std::min(ParameterPackSize, P->ParameterPackSize);
}
: Node(KClosureTypeName), Params(Params_), Count(Count_) {}
void printLeft(OutputStream &S) const override {
S += "\'lambda";
@ -1373,10 +1319,7 @@ class BinaryExpr : public Expr {
public:
BinaryExpr(Node *LHS_, StringView InfixOperator_, Node *RHS_)
: LHS(LHS_), InfixOperator(InfixOperator_), RHS(RHS_) {
ParameterPackSize =
std::min(LHS->ParameterPackSize, RHS->ParameterPackSize);
}
: LHS(LHS_), InfixOperator(InfixOperator_), RHS(RHS_) {}
void printLeft(OutputStream &S) const override {
// might be a template argument expression, then we need to disambiguate
@ -1402,10 +1345,7 @@ class ArraySubscriptExpr : public Expr {
const Node *Op2;
public:
ArraySubscriptExpr(Node *Op1_, Node *Op2_) : Op1(Op1_), Op2(Op2_) {
ParameterPackSize =
std::min(Op1->ParameterPackSize, Op2->ParameterPackSize);
}
ArraySubscriptExpr(Node *Op1_, Node *Op2_) : Op1(Op1_), Op2(Op2_) {}
void printLeft(OutputStream &S) const override {
S += "(";
@ -1422,9 +1362,7 @@ class PostfixExpr : public Expr {
public:
PostfixExpr(Node *Child_, StringView Operand_)
: Child(Child_), Operand(Operand_) {
ParameterPackSize = Child->ParameterPackSize;
}
: Child(Child_), Operand(Operand_) {}
void printLeft(OutputStream &S) const override {
S += "(";
@ -1441,11 +1379,7 @@ class ConditionalExpr : public Expr {
public:
ConditionalExpr(Node *Cond_, Node *Then_, Node *Else_)
: Cond(Cond_), Then(Then_), Else(Else_) {
ParameterPackSize =
std::min(Cond->ParameterPackSize,
std::min(Then->ParameterPackSize, Else->ParameterPackSize));
}
: Cond(Cond_), Then(Then_), Else(Else_) {}
void printLeft(OutputStream &S) const override {
S += "(";
@ -1465,10 +1399,7 @@ class MemberExpr : public Expr {
public:
MemberExpr(Node *LHS_, StringView Kind_, Node *RHS_)
: LHS(LHS_), Kind(Kind_), RHS(RHS_) {
ParameterPackSize =
std::min(LHS->ParameterPackSize, RHS->ParameterPackSize);
}
: LHS(LHS_), Kind(Kind_), RHS(RHS_) {}
void printLeft(OutputStream &S) const override {
LHS->print(S);
@ -1484,9 +1415,7 @@ class EnclosingExpr : public Expr {
public:
EnclosingExpr(StringView Prefix_, Node *Infix_, StringView Postfix_)
: Prefix(Prefix_), Infix(Infix_), Postfix(Postfix_) {
ParameterPackSize = Infix->ParameterPackSize;
}
: Prefix(Prefix_), Infix(Infix_), Postfix(Postfix_) {}
void printLeft(OutputStream &S) const override {
S += Prefix;
@ -1503,10 +1432,7 @@ class CastExpr : public Expr {
public:
CastExpr(StringView CastKind_, Node *To_, Node *From_)
: CastKind(CastKind_), To(To_), From(From_) {
ParameterPackSize =
std::min(To->ParameterPackSize, From->ParameterPackSize);
}
: CastKind(CastKind_), To(To_), From(From_) {}
void printLeft(OutputStream &S) const override {
S += CastKind;
@ -1537,11 +1463,7 @@ class CallExpr : public Expr {
NodeArray Args;
public:
CallExpr(Node *Callee_, NodeArray Args_) : Callee(Callee_), Args(Args_) {
for (Node *P : Args)
ParameterPackSize = std::min(ParameterPackSize, P->ParameterPackSize);
ParameterPackSize = std::min(ParameterPackSize, Callee->ParameterPackSize);
}
CallExpr(Node *Callee_, NodeArray Args_) : Callee(Callee_), Args(Args_) {}
void printLeft(OutputStream &S) const override {
Callee->print(S);
@ -1562,14 +1484,7 @@ public:
NewExpr(NodeArray ExprList_, Node *Type_, NodeArray InitList_, bool IsGlobal_,
bool IsArray_)
: ExprList(ExprList_), Type(Type_), InitList(InitList_),
IsGlobal(IsGlobal_), IsArray(IsArray_) {
for (Node *E : ExprList)
ParameterPackSize = std::min(ParameterPackSize, E->ParameterPackSize);
for (Node *I : InitList)
ParameterPackSize = std::min(ParameterPackSize, I->ParameterPackSize);
if (Type)
ParameterPackSize = std::min(ParameterPackSize, Type->ParameterPackSize);
}
IsGlobal(IsGlobal_), IsArray(IsArray_) {}
void printLeft(OutputStream &S) const override {
if (IsGlobal)
@ -1600,9 +1515,7 @@ class DeleteExpr : public Expr {
public:
DeleteExpr(Node *Op_, bool IsGlobal_, bool IsArray_)
: Op(Op_), IsGlobal(IsGlobal_), IsArray(IsArray_) {
ParameterPackSize = Op->ParameterPackSize;
}
: Op(Op_), IsGlobal(IsGlobal_), IsArray(IsArray_) {}
void printLeft(OutputStream &S) const override {
if (IsGlobal)
@ -1619,9 +1532,7 @@ class PrefixExpr : public Expr {
Node *Child;
public:
PrefixExpr(StringView Prefix_, Node *Child_) : Prefix(Prefix_), Child(Child_) {
ParameterPackSize = Child->ParameterPackSize;
}
PrefixExpr(StringView Prefix_, Node *Child_) : Prefix(Prefix_), Child(Child_) {}
void printLeft(OutputStream &S) const override {
S += Prefix;
@ -1649,11 +1560,7 @@ class ConversionExpr : public Expr {
public:
ConversionExpr(const Node *Type_, NodeArray Expressions_)
: Type(Type_), Expressions(Expressions_) {
for (Node *E : Expressions)
ParameterPackSize = std::min(ParameterPackSize, E->ParameterPackSize);
ParameterPackSize = std::min(ParameterPackSize, Type->ParameterPackSize);
}
: Type(Type_), Expressions(Expressions_) {}
void printLeft(OutputStream &S) const override {
S += "(";
@ -1668,13 +1575,7 @@ class InitListExpr : public Expr {
Node *Ty;
NodeArray Inits;
public:
InitListExpr(Node *Ty_, NodeArray Inits_)
: Ty(Ty_), Inits(Inits_) {
if (Ty)
ParameterPackSize = Ty->ParameterPackSize;
for (Node *I : Inits)
ParameterPackSize = std::min(I->ParameterPackSize, ParameterPackSize);
}
InitListExpr(Node *Ty_, NodeArray Inits_) : Ty(Ty_), Inits(Inits_) {}
void printLeft(OutputStream &S) const override {
if (Ty)
@ -1732,9 +1633,7 @@ class ThrowExpr : public Expr {
const Node *Op;
public:
ThrowExpr(Node *Op_) : Op(Op_) {
ParameterPackSize = Op->ParameterPackSize;
}
ThrowExpr(Node *Op_) : Op(Op_) {}
void printLeft(OutputStream &S) const override {
S += "throw ";
@ -1759,9 +1658,8 @@ class IntegerCastExpr : public Expr {
StringView Integer;
public:
IntegerCastExpr(Node *Ty_, StringView Integer_) : Ty(Ty_), Integer(Integer_) {
ParameterPackSize = Ty->ParameterPackSize;
}
IntegerCastExpr(Node *Ty_, StringView Integer_)
: Ty(Ty_), Integer(Integer_) {}
void printLeft(OutputStream &S) const override {
S += "(";
@ -4896,9 +4794,6 @@ char *llvm::itaniumDemangle(const char *MangledName, char *Buf,
InternalStatus = invalid_mangled_name;
}
if (InternalStatus == success && AST->containsUnexpandedParameterPack())
InternalStatus = invalid_mangled_name;
if (InternalStatus == success) {
if (Buf == nullptr) {
BufSize = 1024;