[libcxx-commits] [libcxxabi] 704b21c - [demangler] Remove StdQualifiedName

Nathan Sidwell via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 7 07:49:46 PST 2022


Author: Nathan Sidwell
Date: 2022-02-07T07:49:30-08:00
New Revision: 704b21cb4fa5323564779b1a39b577b2481bf677

URL: https://github.com/llvm/llvm-project/commit/704b21cb4fa5323564779b1a39b577b2481bf677
DIFF: https://github.com/llvm/llvm-project/commit/704b21cb4fa5323564779b1a39b577b2481bf677.diff

LOG: [demangler] Remove StdQualifiedName

The StdQualifiedName node class is used for names exactly in the std
namespace.  It is not used for nested names that descend further --
those use a NestedName with NameType("std") as the scope.
Representing the compression scheme in the node graph is layer
breaking.  We can use the same structure for those exactly in std too,
and reduce code size a bit.

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D118249

Added: 
    

Modified: 
    libcxxabi/src/demangle/ItaniumDemangle.h
    llvm/include/llvm/Demangle/ItaniumDemangle.h
    llvm/lib/Demangle/ItaniumDemangle.cpp
    llvm/lib/Support/ItaniumManglingCanonicalizer.cpp

Removed: 
    


################################################################################
diff  --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index db65c60e7e5e6..b835345bed220 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -73,7 +73,6 @@
     X(ForwardTemplateReference) \
     X(NameWithTemplateArgs) \
     X(GlobalQualifiedName) \
-    X(StdQualifiedName) \
     X(ExpandedSpecialSubstitution) \
     X(SpecialSubstitution) \
     X(CtorDtorName) \
@@ -1473,21 +1472,6 @@ class GlobalQualifiedName final : public Node {
   }
 };
 
-struct StdQualifiedName : Node {
-  Node *Child;
-
-  StdQualifiedName(Node *Child_) : Node(KStdQualifiedName), Child(Child_) {}
-
-  template<typename Fn> void match(Fn F) const { F(Child); }
-
-  StringView getBaseName() const override { return Child->getBaseName(); }
-
-  void printLeft(OutputBuffer &OB) const override {
-    OB += "std::";
-    Child->print(OB);
-  }
-};
-
 enum class SpecialSubKind {
   allocator,
   basic_string,
@@ -2678,8 +2662,12 @@ AbstractManglingParser<Derived, Alloc>::parseUnscopedName(NameState *State) {
   Node *Result = getDerived().parseUnqualifiedName(State);
   if (Result == nullptr)
     return nullptr;
-  if (IsStd)
-    Result = make<StdQualifiedName>(Result);
+  if (IsStd) {
+    if (auto *Std = make<NameType>("std"))
+      Result = make<NestedName>(Std, Result);
+    else
+      return nullptr;
+  }
 
   return Result;
 }

diff  --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index f6acd623eb912..6ac77124ed07c 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -73,7 +73,6 @@
     X(ForwardTemplateReference) \
     X(NameWithTemplateArgs) \
     X(GlobalQualifiedName) \
-    X(StdQualifiedName) \
     X(ExpandedSpecialSubstitution) \
     X(SpecialSubstitution) \
     X(CtorDtorName) \
@@ -1473,21 +1472,6 @@ class GlobalQualifiedName final : public Node {
   }
 };
 
-struct StdQualifiedName : Node {
-  Node *Child;
-
-  StdQualifiedName(Node *Child_) : Node(KStdQualifiedName), Child(Child_) {}
-
-  template<typename Fn> void match(Fn F) const { F(Child); }
-
-  StringView getBaseName() const override { return Child->getBaseName(); }
-
-  void printLeft(OutputBuffer &OB) const override {
-    OB += "std::";
-    Child->print(OB);
-  }
-};
-
 enum class SpecialSubKind {
   allocator,
   basic_string,
@@ -2678,8 +2662,12 @@ AbstractManglingParser<Derived, Alloc>::parseUnscopedName(NameState *State) {
   Node *Result = getDerived().parseUnqualifiedName(State);
   if (Result == nullptr)
     return nullptr;
-  if (IsStd)
-    Result = make<StdQualifiedName>(Result);
+  if (IsStd) {
+    if (auto *Std = make<NameType>("std"))
+      Result = make<NestedName>(Std, Result);
+    else
+      return nullptr;
+  }
 
   return Result;
 }

diff  --git a/llvm/lib/Demangle/ItaniumDemangle.cpp b/llvm/lib/Demangle/ItaniumDemangle.cpp
index 1a5db755e37b5..06a74c12316cd 100644
--- a/llvm/lib/Demangle/ItaniumDemangle.cpp
+++ b/llvm/lib/Demangle/ItaniumDemangle.cpp
@@ -404,9 +404,6 @@ char *ItaniumPartialDemangler::getFunctionBaseName(char *Buf, size_t *N) const {
     case Node::KAbiTagAttr:
       Name = static_cast<const AbiTagAttr *>(Name)->Base;
       continue;
-    case Node::KStdQualifiedName:
-      Name = static_cast<const StdQualifiedName *>(Name)->Child;
-      continue;
     case Node::KNestedName:
       Name = static_cast<const NestedName *>(Name)->Name;
       continue;
@@ -446,9 +443,6 @@ char *ItaniumPartialDemangler::getFunctionDeclContextName(char *Buf,
   }
 
   switch (Name->getKind()) {
-  case Node::KStdQualifiedName:
-    OB += "std";
-    break;
   case Node::KNestedName:
     static_cast<const NestedName *>(Name)->Qual->print(OB);
     break;
@@ -550,9 +544,6 @@ bool ItaniumPartialDemangler::isCtorOrDtor() const {
     case Node::KNestedName:
       N = static_cast<const NestedName *>(N)->Name;
       break;
-    case Node::KStdQualifiedName:
-      N = static_cast<const StdQualifiedName *>(N)->Child;
-      break;
     }
   }
   return false;

diff  --git a/llvm/lib/Support/ItaniumManglingCanonicalizer.cpp b/llvm/lib/Support/ItaniumManglingCanonicalizer.cpp
index e6cba26cfcf37..52d5de93ff7d7 100644
--- a/llvm/lib/Support/ItaniumManglingCanonicalizer.cpp
+++ b/llvm/lib/Support/ItaniumManglingCanonicalizer.cpp
@@ -189,20 +189,6 @@ class CanonicalizerAllocator : public FoldingNodeAllocator {
   bool trackedNodeIsUsed() const { return TrackedNodeIsUsed; }
 };
 
-/// Convert St3foo to NSt3fooE so that equivalences naming one also affect the
-/// other.
-template<>
-struct CanonicalizerAllocator::MakeNodeImpl<
-           itanium_demangle::StdQualifiedName> {
-  CanonicalizerAllocator &Self;
-  Node *make(Node *Child) {
-    Node *StdNamespace = Self.makeNode<itanium_demangle::NameType>("std");
-    if (!StdNamespace)
-      return nullptr;
-    return Self.makeNode<itanium_demangle::NestedName>(StdNamespace, Child);
-  }
-};
-
 // FIXME: Also expand built-in substitutions?
 
 using CanonicalizingDemangler =


        


More information about the libcxx-commits mailing list