@@ -607,48 +607,12 @@ class PointerToMemberType final : public Node {
607607 }
608608};
609609
610- class NodeOrString {
611- const void *First;
612- const void *Second;
613-
614- public:
615- /* implicit */ NodeOrString(StringView Str) {
616- const char *FirstChar = Str.begin ();
617- const char *SecondChar = Str.end ();
618- if (SecondChar == nullptr ) {
619- assert (FirstChar == SecondChar);
620- ++FirstChar, ++SecondChar;
621- }
622- First = static_cast <const void *>(FirstChar);
623- Second = static_cast <const void *>(SecondChar);
624- }
625-
626- /* implicit */ NodeOrString(Node *N)
627- : First(static_cast <const void *>(N)), Second(nullptr ) {}
628- NodeOrString () : First(nullptr ), Second(nullptr ) {}
629-
630- bool isString () const { return Second && First; }
631- bool isNode () const { return First && !Second; }
632- bool isEmpty () const { return !First && !Second; }
633-
634- StringView asString () const {
635- assert (isString ());
636- return StringView (static_cast <const char *>(First),
637- static_cast <const char *>(Second));
638- }
639-
640- const Node *asNode () const {
641- assert (isNode ());
642- return static_cast <const Node *>(First);
643- }
644- };
645-
646610class ArrayType final : public Node {
647611 const Node *Base;
648- NodeOrString Dimension;
612+ Node * Dimension;
649613
650614public:
651- ArrayType (const Node *Base_, NodeOrString Dimension_)
615+ ArrayType (const Node *Base_, Node * Dimension_)
652616 : Node(KArrayType,
653617 /* RHSComponentCache=*/ Cache::Yes,
654618 /* ArrayCache=*/ Cache::Yes),
@@ -665,10 +629,8 @@ class ArrayType final : public Node {
665629 if (S.back () != ' ]' )
666630 S += " " ;
667631 S += " [" ;
668- if (Dimension.isString ())
669- S += Dimension.asString ();
670- else if (Dimension.isNode ())
671- Dimension.asNode ()->print (S);
632+ if (Dimension)
633+ Dimension->print (S);
672634 S += " ]" ;
673635 Base->printRight (S);
674636 }
@@ -934,10 +896,10 @@ class QualifiedName final : public Node {
934896
935897class VectorType final : public Node {
936898 const Node *BaseType;
937- const NodeOrString Dimension;
899+ const Node * Dimension;
938900
939901public:
940- VectorType (const Node *BaseType_, NodeOrString Dimension_)
902+ VectorType (const Node *BaseType_, Node * Dimension_)
941903 : Node(KVectorType), BaseType(BaseType_),
942904 Dimension (Dimension_) {}
943905
@@ -946,27 +908,25 @@ class VectorType final : public Node {
946908 void printLeft (OutputStream &S) const override {
947909 BaseType->print (S);
948910 S += " vector[" ;
949- if (Dimension.isNode ())
950- Dimension.asNode ()->print (S);
951- else if (Dimension.isString ())
952- S += Dimension.asString ();
911+ if (Dimension)
912+ Dimension->print (S);
953913 S += " ]" ;
954914 }
955915};
956916
957917class PixelVectorType final : public Node {
958- const NodeOrString Dimension;
918+ const Node * Dimension;
959919
960920public:
961- PixelVectorType (NodeOrString Dimension_)
921+ PixelVectorType (const Node * Dimension_)
962922 : Node(KPixelVectorType), Dimension(Dimension_) {}
963923
964924 template <typename Fn> void match (Fn F) const { F (Dimension); }
965925
966926 void printLeft (OutputStream &S) const override {
967927 // FIXME: This should demangle as "vector pixel".
968928 S += " pixel vector[" ;
969- S += Dimension. asString ( );
929+ Dimension-> print (S );
970930 S += " ]" ;
971931 }
972932};
@@ -3548,7 +3508,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseVectorType() {
35483508 if (!consumeIf (" Dv" ))
35493509 return nullptr ;
35503510 if (look () >= ' 1' && look () <= ' 9' ) {
3551- StringView DimensionNumber = parseNumber ();
3511+ Node *DimensionNumber = make<NameType>(parseNumber ());
3512+ if (!DimensionNumber)
3513+ return nullptr ;
35523514 if (!consumeIf (' _' ))
35533515 return nullptr ;
35543516 if (consumeIf (' p' ))
@@ -3573,7 +3535,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseVectorType() {
35733535 Node *ElemType = getDerived ().parseType ();
35743536 if (!ElemType)
35753537 return nullptr ;
3576- return make<VectorType>(ElemType, StringView () );
3538+ return make<VectorType>(ElemType, /* Dimension= */ nullptr );
35773539}
35783540
35793541// <decltype> ::= Dt <expression> E # decltype of an id-expression or class member access (C++0x)
@@ -3599,10 +3561,12 @@ Node *AbstractManglingParser<Derived, Alloc>::parseArrayType() {
35993561 if (!consumeIf (' A' ))
36003562 return nullptr ;
36013563
3602- NodeOrString Dimension;
3564+ Node * Dimension = nullptr ;
36033565
36043566 if (std::isdigit (look ())) {
3605- Dimension = parseNumber ();
3567+ Dimension = make<NameType>(parseNumber ());
3568+ if (!Dimension)
3569+ return nullptr ;
36063570 if (!consumeIf (' _' ))
36073571 return nullptr ;
36083572 } else if (!consumeIf (' _' )) {
0 commit comments