[libcxxabi] r344121 - Port llvm r342166 to libcxxabi demangler

Pavel Labath pavel at labath.sk
Wed Oct 10 01:39:17 PDT 2018


Author: labath
Date: Wed Oct 10 01:39:16 2018
New Revision: 344121

URL: http://llvm.org/viewvc/llvm-project?rev=344121&view=rev
Log:
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

Modified:
    libcxxabi/trunk/src/demangle/ItaniumDemangle.h

Modified: libcxxabi/trunk/src/demangle/ItaniumDemangle.h
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/demangle/ItaniumDemangle.h?rev=344121&r1=344120&r2=344121&view=diff
==============================================================================
--- libcxxabi/trunk/src/demangle/ItaniumDemangle.h (original)
+++ libcxxabi/trunk/src/demangle/ItaniumDemangle.h Wed Oct 10 01:39:16 2018
@@ -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
     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>
   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>




More information about the libcxx-commits mailing list