[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
GitOrigin-RevId: 704b21cb4fa5323564779b1a39b577b2481bf677
diff --git a/src/demangle/ItaniumDemangle.h b/src/demangle/ItaniumDemangle.h
index db65c60..b835345 100644
--- a/src/demangle/ItaniumDemangle.h
+++ b/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 @@
}
};
-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 @@
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;
}