diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h --- a/libcxxabi/src/demangle/ItaniumDemangle.h +++ b/libcxxabi/src/demangle/ItaniumDemangle.h @@ -457,7 +457,7 @@ const StringView Postfix; public: - PostfixQualifiedType(Node *Ty_, StringView Postfix_) + PostfixQualifiedType(const Node *Ty_, StringView Postfix_) : Node(KPostfixQualifiedType), Ty(Ty_), Postfix(Postfix_) {} template void match(Fn F) const { F(Ty, Postfix); } @@ -1047,9 +1047,8 @@ const Node *Dimension; public: - VectorType(const Node *BaseType_, Node *Dimension_) - : Node(KVectorType), BaseType(BaseType_), - Dimension(Dimension_) {} + VectorType(const Node *BaseType_, const Node *Dimension_) + : Node(KVectorType), BaseType(BaseType_), Dimension(Dimension_) {} template void match(Fn F) const { F(BaseType, Dimension); } @@ -1846,7 +1845,8 @@ const StringView Postfix; public: - EnclosingExpr(StringView Prefix_, Node *Infix_, Prec Prec_ = Prec::Primary) + EnclosingExpr(StringView Prefix_, const Node *Infix_, + Prec Prec_ = Prec::Primary) : Node(KEnclosingExpr, Prec_), Prefix(Prefix_), Infix(Infix_) {} template void match(Fn F) const { diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h --- a/llvm/include/llvm/Demangle/ItaniumDemangle.h +++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h @@ -457,7 +457,7 @@ const StringView Postfix; public: - PostfixQualifiedType(Node *Ty_, StringView Postfix_) + PostfixQualifiedType(const Node *Ty_, StringView Postfix_) : Node(KPostfixQualifiedType), Ty(Ty_), Postfix(Postfix_) {} template void match(Fn F) const { F(Ty, Postfix); } @@ -1047,9 +1047,8 @@ const Node *Dimension; public: - VectorType(const Node *BaseType_, Node *Dimension_) - : Node(KVectorType), BaseType(BaseType_), - Dimension(Dimension_) {} + VectorType(const Node *BaseType_, const Node *Dimension_) + : Node(KVectorType), BaseType(BaseType_), Dimension(Dimension_) {} template void match(Fn F) const { F(BaseType, Dimension); } @@ -1846,7 +1845,8 @@ const StringView Postfix; public: - EnclosingExpr(StringView Prefix_, Node *Infix_, Prec Prec_ = Prec::Primary) + EnclosingExpr(StringView Prefix_, const Node *Infix_, + Prec Prec_ = Prec::Primary) : Node(KEnclosingExpr, Prec_), Prefix(Prefix_), Infix(Infix_) {} template void match(Fn F) const { diff --git a/llvm/unittests/Demangle/ItaniumDemangleTest.cpp b/llvm/unittests/Demangle/ItaniumDemangleTest.cpp --- a/llvm/unittests/Demangle/ItaniumDemangleTest.cpp +++ b/llvm/unittests/Demangle/ItaniumDemangleTest.cpp @@ -34,6 +34,28 @@ }; } // namespace +namespace { +// Make sure the node matchers provide constructor parameters. This is a +// compilation test. +template struct Ctor { + template void operator()(Args &&...args) { + auto _ = NT(std::forward(args)...); + } +}; + +template void Visit(const NT *Node) { Node->match(Ctor{}); } +#define NOMATCHER(X) \ + template <> void Visit(const itanium_demangle::X *) {} +// Some nodes have no match member. +NOMATCHER(ForwardTemplateReference) +#undef NOMATCHER + +void __attribute__((used)) Visitor() { +#define NODE(X) Visit(static_cast(nullptr)); +#include "llvm/Demangle/ItaniumNodes.def" +} +} // namespace + TEST(ItaniumDemangle, MethodOverride) { struct TestParser : AbstractManglingParser { std::vector Types;