summaryrefslogtreecommitdiff
path: root/libcxxabi/src
diff options
context:
space:
mode:
authorErik Pilkington <erik.pilkington@gmail.com>2018-03-25 22:49:57 +0000
committerErik Pilkington <erik.pilkington@gmail.com>2018-03-25 22:49:57 +0000
commit19fb1e3fd16090efaa93327deb0bcf6651c483b7 (patch)
treee8735eb1fb618cf3f80e3e5ab9cc1b1a05298b2e /libcxxabi/src
parent90c0d85c3ee48e8c76bd262548e432cfbb211865 (diff)
[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.
Diffstat (limited to 'libcxxabi/src')
-rw-r--r--libcxxabi/src/cxa_demangle.cpp315
1 files changed, 105 insertions, 210 deletions
diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp
index 80b0ebeb020..2e5b657a634 100644
--- a/libcxxabi/src/cxa_demangle.cpp
+++ b/libcxxabi/src/cxa_demangle.cpp
@@ -109,6 +109,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();
@@ -126,7 +127,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';
@@ -203,10 +205,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
@@ -225,17 +223,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;
@@ -260,10 +252,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)
@@ -316,12 +304,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;
}
}
};
@@ -348,8 +344,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);
@@ -391,7 +386,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_) {}
@@ -418,7 +413,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 ";
@@ -432,8 +427,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);
@@ -458,9 +452,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;
@@ -474,7 +466,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_) {}
@@ -527,8 +519,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 {
@@ -568,8 +559,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 {
@@ -597,8 +587,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 {
@@ -628,10 +617,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 {
@@ -697,18 +683,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_) {}
@@ -741,17 +723,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; }
@@ -796,7 +772,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(";
@@ -809,10 +785,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(";
@@ -832,16 +805,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; }
@@ -885,8 +853,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\"\" ";
@@ -900,8 +867,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;
@@ -915,8 +881,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 {
@@ -934,9 +899,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(); }
@@ -961,17 +924,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) {
@@ -1000,9 +956,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;
@@ -1019,24 +983,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);
@@ -1052,10 +1021,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; }
@@ -1076,60 +1042,49 @@ public:
const Node *getChild() const { return Child; }
void printLeft(OutputStream &S) const override {
- unsigned PackSize = Child->ParameterPackSize;
- if (PackSize == NoParameterPack) {
- Child->print(S);
+ 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)
- S += ", ";
+ // 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);
}
}
};
-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 += ">";
@@ -1143,9 +1098,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(); }
@@ -1160,7 +1113,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(); }
@@ -1174,8 +1127,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(); }
@@ -1298,8 +1250,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)
@@ -1312,9 +1263,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 += "~";
@@ -1341,10 +1290,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";
@@ -1381,10 +1327,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
@@ -1410,10 +1353,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 += "(";
@@ -1430,9 +1370,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 += "(";
@@ -1449,11 +1387,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 += "(";
@@ -1473,10 +1407,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);
@@ -1492,9 +1423,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;
@@ -1511,10 +1440,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;
@@ -1545,11 +1471,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);
@@ -1570,14 +1492,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)
@@ -1608,9 +1523,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)
@@ -1627,9 +1540,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;
@@ -1657,11 +1568,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 += "(";
@@ -1676,13 +1583,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)
@@ -1740,9 +1641,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 ";
@@ -1767,9 +1666,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 += "(";
@@ -4905,9 +4803,6 @@ __cxa_demangle(const char *MangledName, char *Buf, size_t *N, int *Status) {
InternalStatus = invalid_mangled_name;
}
- if (InternalStatus == success && AST->containsUnexpandedParameterPack())
- InternalStatus = invalid_mangled_name;
-
if (InternalStatus == success) {
if (Buf == nullptr) {
BufSize = 1024;