diff options
author | Pavel Labath <pavel@labath.sk> | 2018-10-10 08:39:16 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2018-10-10 08:39:16 +0000 |
commit | d1d4ce5d9bcf8a63e810074a7c73ce33da71c200 (patch) | |
tree | e4c3e98d877f944e1b9053eeee00fdda91b926ac /libcxxabi | |
parent | c14370f9f0ed75f7b102e8fef8f82530dca86b87 (diff) |
Port llvm r342166 to libcxxabi demangler
Summary:
This was committed back in september (D51463), but it seems it never
made it into the libcxxabi copy.
The original commit message was:
The hash computed for an ArrayType was different when first constructed
versus when later profiled due to the constructor default argument, and
we were not tracking constructor / destructor variant as part of the
mangled name AST, leading to incorrect equivalences.
Reviewers: erik.pilkington, rsmith, EricWF
Subscribers: christof, ldionne, libcxx-commits
Differential Revision: https://reviews.llvm.org/D53063
Diffstat (limited to 'libcxxabi')
-rw-r--r-- | libcxxabi/src/demangle/ItaniumDemangle.h | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h index e475197abf7..32da9ffcb14 100644 --- a/libcxxabi/src/demangle/ItaniumDemangle.h +++ b/libcxxabi/src/demangle/ItaniumDemangle.h @@ -642,7 +642,7 @@ class ArrayType final : public Node { NodeOrString Dimension; public: - ArrayType(const Node *Base_, NodeOrString Dimension_ = NodeOrString()) + ArrayType(const Node *Base_, NodeOrString Dimension_) : Node(KArrayType, /*RHSComponentCache=*/Cache::Yes, /*ArrayCache=*/Cache::Yes), @@ -1365,12 +1365,14 @@ public: class CtorDtorName final : public Node { const Node *Basename; const bool IsDtor; + const int Variant; public: - CtorDtorName(const Node *Basename_, bool IsDtor_) - : Node(KCtorDtorName), Basename(Basename_), IsDtor(IsDtor_) {} + CtorDtorName(const Node *Basename_, bool IsDtor_, int Variant_) + : Node(KCtorDtorName), Basename(Basename_), IsDtor(IsDtor_), + Variant(Variant_) {} - template<typename Fn> void match(Fn F) const { F(Basename, IsDtor); } + template<typename Fn> void match(Fn F) const { F(Basename, IsDtor, Variant); } void printLeft(OutputStream &S) const override { if (IsDtor) @@ -2805,20 +2807,22 @@ Node *Db<Alloc>::parseCtorDtorName(Node *&SoFar, NameState *State) { bool IsInherited = consumeIf('I'); if (look() != '1' && look() != '2' && look() != '3' && look() != '5') return nullptr; + int Variant = look() - '0'; ++First; if (State) State->CtorDtorConversion = true; if (IsInherited) { if (parseName(State) == nullptr) return nullptr; } - return make<CtorDtorName>(SoFar, false); + return make<CtorDtorName>(SoFar, false, Variant); } if (look() == 'D' && (look(1) == '0' || look(1) == '1' || look(1) == '2' || look(1) == '5')) { + int Variant = look(1) - '0'; First += 2; if (State) State->CtorDtorConversion = true; - return make<CtorDtorName>(SoFar, true); + return make<CtorDtorName>(SoFar, true, Variant); } return nullptr; @@ -3297,32 +3301,25 @@ template<typename Alloc> Node *Db<Alloc>::parseArrayType() { if (!consumeIf('A')) return nullptr; + NodeOrString Dimension; + if (std::isdigit(look())) { - StringView Dimension = parseNumber(); + Dimension = parseNumber(); if (!consumeIf('_')) return nullptr; - Node *Ty = parseType(); - if (Ty == nullptr) - return nullptr; - return make<ArrayType>(Ty, Dimension); - } - - if (!consumeIf('_')) { + } else if (!consumeIf('_')) { Node *DimExpr = parseExpr(); if (DimExpr == nullptr) return nullptr; if (!consumeIf('_')) return nullptr; - Node *ElementType = parseType(); - if (ElementType == nullptr) - return nullptr; - return make<ArrayType>(ElementType, DimExpr); + Dimension = DimExpr; } Node *Ty = parseType(); if (Ty == nullptr) return nullptr; - return make<ArrayType>(Ty); + return make<ArrayType>(Ty, Dimension); } // <pointer-to-member-type> ::= M <class type> <member type> |