forked from OSchip/llvm-project
[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
This commit is contained in:
parent
3d7662142d
commit
704b21cb4f
|
@ -73,7 +73,6 @@
|
|||
X(ForwardTemplateReference) \
|
||||
X(NameWithTemplateArgs) \
|
||||
X(GlobalQualifiedName) \
|
||||
X(StdQualifiedName) \
|
||||
X(ExpandedSpecialSubstitution) \
|
||||
X(SpecialSubstitution) \
|
||||
X(CtorDtorName) \
|
||||
|
@ -1473,21 +1472,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
X(ForwardTemplateReference) \
|
||||
X(NameWithTemplateArgs) \
|
||||
X(GlobalQualifiedName) \
|
||||
X(StdQualifiedName) \
|
||||
X(ExpandedSpecialSubstitution) \
|
||||
X(SpecialSubstitution) \
|
||||
X(CtorDtorName) \
|
||||
|
@ -1473,21 +1472,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -189,20 +189,6 @@ public:
|
|||
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 =
|
||||
|
|
Loading…
Reference in New Issue