@@ -352,11 +352,12 @@ NodePointer NodeFactory::createNode(Node::Kind K) {
352
352
NodePointer NodeFactory::createNode (Node::Kind K, Node::IndexType Index) {
353
353
return new (Allocate<Node>()) Node (K, Index);
354
354
}
355
- NodePointer NodeFactory::createNode (Node::Kind K, llvm::StringRef Text) {
356
- return new (Allocate<Node>()) Node (K, Text.copy (*this ));
355
+ NodePointer NodeFactory::createNodeWithAllocatedText (Node::Kind K,
356
+ llvm::StringRef Text) {
357
+ return new (Allocate<Node>()) Node (K, Text);
357
358
}
358
359
NodePointer NodeFactory::createNode (Node::Kind K, const CharVector &Text) {
359
- return new (Allocate<Node>()) Node (K, Text.str ());
360
+ return createNodeWithAllocatedText (K, Text.str ());
360
361
}
361
362
NodePointer NodeFactory::createNode (Node::Kind K, const char *Text) {
362
363
return new (Allocate<Node>()) Node (K, llvm::StringRef (Text));
@@ -527,7 +528,7 @@ NodePointer Demangler::changeKind(NodePointer Node, Node::Kind NewKind) {
527
528
return nullptr ;
528
529
NodePointer NewNode = nullptr ;
529
530
if (Node->hasText ()) {
530
- NewNode = createNode (NewKind, Node->getText ());
531
+ NewNode = createNodeWithAllocatedText (NewKind, Node->getText ());
531
532
} else if (Node->hasIndex ()) {
532
533
NewNode = createNode (NewKind, Node->getIndex ());
533
534
} else {
@@ -649,7 +650,7 @@ NodePointer Demangler::demangleMultiSubstitutions() {
649
650
}
650
651
}
651
652
652
- NodePointer Demangler::createSwiftType (Node::Kind typeKind, StringRef name) {
653
+ NodePointer Demangler::createSwiftType (Node::Kind typeKind, const char * name) {
653
654
return createType (createWithChildren (typeKind,
654
655
createNode (Node::Kind::Module, STDLIB_NAME),
655
656
createNode (Node::Kind::Identifier, name)));
@@ -985,8 +986,9 @@ NodePointer Demangler::popTuple() {
985
986
firstElem = (popNode (Node::Kind::FirstElementMarker) != nullptr );
986
987
NodePointer TupleElmt = createNode (Node::Kind::TupleElement);
987
988
if (NodePointer Ident = popNode (Node::Kind::Identifier)) {
988
- TupleElmt->addChild (createNode (Node::Kind::TupleElementName,
989
- Ident->getText ()), *this );
989
+ TupleElmt->addChild (createNodeWithAllocatedText (
990
+ Node::Kind::TupleElementName, Ident->getText ()),
991
+ *this );
990
992
}
991
993
NodePointer Ty = popNode (Node::Kind::Type);
992
994
if (!Ty)
@@ -1135,7 +1137,7 @@ NodePointer Demangler::demangleImplFunctionType() {
1135
1137
if (GenSig && nextIf (' P' ))
1136
1138
GenSig = changeKind (GenSig, Node::Kind::DependentPseudogenericSignature);
1137
1139
1138
- StringRef CAttr;
1140
+ const char * CAttr = nullptr ;
1139
1141
switch (nextChar ()) {
1140
1142
case ' y' : CAttr = " @callee_unowned" ; break ;
1141
1143
case ' g' : CAttr = " @callee_guaranteed" ; break ;
@@ -1145,7 +1147,7 @@ NodePointer Demangler::demangleImplFunctionType() {
1145
1147
}
1146
1148
type->addChild (createNode (Node::Kind::ImplConvention, CAttr), *this );
1147
1149
1148
- StringRef FAttr;
1150
+ const char * FAttr = nullptr ;
1149
1151
switch (nextChar ()) {
1150
1152
case ' B' : FAttr = " @convention(block)" ; break ;
1151
1153
case ' C' : FAttr = " @convention(c)" ; break ;
@@ -1157,7 +1159,7 @@ NodePointer Demangler::demangleImplFunctionType() {
1157
1159
pushBack ();
1158
1160
break ;
1159
1161
}
1160
- if (! FAttr. empty () )
1162
+ if (FAttr)
1161
1163
type->addChild (createNode (Node::Kind::ImplFunctionAttribute, FAttr), *this );
1162
1164
1163
1165
addChild (type, GenSig);
@@ -1473,7 +1475,7 @@ NodePointer Demangler::demangleFunctionSpecialization() {
1473
1475
// A '_' escapes a leading digit or '_' of a string constant.
1474
1476
Text = Text.drop_front (1 );
1475
1477
}
1476
- addChild (Param, createNode (
1478
+ addChild (Param, createNodeWithAllocatedText (
1477
1479
Node::Kind::FunctionSignatureSpecializationParamPayload, Text));
1478
1480
Param->reverseChildren (FixedChildren);
1479
1481
break ;
@@ -1523,7 +1525,7 @@ NodePointer Demangler::demangleFuncSpecParam(Node::IndexType ParamIdx) {
1523
1525
case ' s' : {
1524
1526
// Consumes an identifier parameter (the string constant),
1525
1527
// which will be added later.
1526
- StringRef Encoding;
1528
+ const char * Encoding = nullptr ;
1527
1529
switch (nextChar ()) {
1528
1530
case ' b' : Encoding = " u8" ; break ;
1529
1531
case ' w' : Encoding = " u16" ; break ;
0 commit comments