Skip to content

Commit c671717

Browse files
committed
Fix re-mangling of function specialization constant strings which start with a digit.
1 parent 493a7ce commit c671717

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Basic/Remangler.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,17 @@ void Remangler::mangleFunctionSignatureSpecialization(Node *node) {
830830
case FunctionSigSpecializationParamKind::ConstantPropGlobal:
831831
mangleIdentifier(Param->getChild(1).get());
832832
break;
833-
case FunctionSigSpecializationParamKind::ConstantPropString:
834-
mangleIdentifier(Param->getChild(2).get());
833+
case FunctionSigSpecializationParamKind::ConstantPropString: {
834+
NodePointer TextNd = Param->getChild(2);
835+
StringRef Text = TextNd->getText();
836+
if (Text.size() > 0 && (isDigit(Text[0]) || Text[0] == '_')) {
837+
std::string Buffer = "_";
838+
Buffer.append(Text.data(), Text.size());
839+
TextNd = NodeFactory::create(Node::Kind::Identifier, Buffer);
840+
}
841+
mangleIdentifier(TextNd.get());
835842
break;
843+
}
836844
case FunctionSigSpecializationParamKind::ClosureProp:
837845
mangleIdentifier(Param->getChild(1).get());
838846
for (unsigned i = 2, e = Param->getNumChildren(); i != e; ++i) {

test/Demangle/Inputs/manglings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,6 @@ _TFVFE15nested_genericsSS3fooFT_T_L_6CheeseCfT8materialx_GS0_x_ ---> (extension
239239
_TTWOE5imojiCSo5Imoji14ImojiMatchRankS_9RankValueS_FS2_g9rankValueqq_Ss16RawRepresentable8RawValue ---> _TTWOE5imojiCSo5Imoji14ImojiMatchRankS_9RankValueS_FS2_g9rankValueqq_Ss16RawRepresentable8RawValue
240240
_TtFzas4VoidGC16FusionXBaseUtils6FutureQq_ZFVS_7Futures6futureurFFzT_GS0_x_GS0_x__ ---> _TtFzas4VoidGC16FusionXBaseUtils6FutureQq_ZFVS_7Futures6futureurFFzT_GS0_x_GS0_x__
241241
_T0s17MutableCollectionP1asAARzs012RandomAccessB0RzsAA11SubSequences013BidirectionalB0PRpzsAdHRQlE06rotatecD05Indexs01_A9IndexablePQzAM15shiftingToStart_tFAJs01_J4BasePQzAQcfU_ ---> (extension in a):Swift.MutableCollection<A where A: Swift.MutableCollection, A: Swift.RandomAccessCollection, A.SubSequence: Swift.MutableCollection, A.SubSequence: Swift.RandomAccessCollection>.(rotateRandomAccess (shiftingToStart : A.Index) -> A.Index).(closure #1)
242+
_T03foo4_123ABTf3psbpsb_n ---> function signature specialization <Arg[0] = [Constant Propagated String : u8'123'], Arg[1] = [Constant Propagated String : u8'123']> of foo
242243
_T04main5innerys5Int32Vz_yADctF25closure_with_box_argumentxz_Bi32__lXXTf1nc_n ---> function signature specialization <Arg[1] = [Closure Propagated : closure_with_box_argument, Argument Types : [<A> { var A } <Builtin.Int32>]> of main.inner (inout Swift.Int32, (Swift.Int32) -> ()) -> ()
243244

0 commit comments

Comments
 (0)