Skip to content

Commit d2a800b

Browse files
authored
Merge pull request #9526 from eeckstein/thunks
2 parents a063e5b + 52aa8ef commit d2a800b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/Demangling/Context.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ bool Context::isThunkSymbol(llvm::StringRef MangledName) {
8383
MangledName.endswith("Ta") || // ObjC partial application forwarder
8484
MangledName.endswith("To") || // swift-as-ObjC thunk
8585
MangledName.endswith("TO") || // ObjC-as-swift thunk
86+
MangledName.endswith("TR") || // reabstraction thunk helper function
87+
MangledName.endswith("Tr") || // reabstraction thunk
8688
MangledName.endswith("TW")) { // protocol witness thunk
8789

8890
// To avoid false positives, we need to fully demangle the symbol.
@@ -96,6 +98,8 @@ bool Context::isThunkSymbol(llvm::StringRef MangledName) {
9698
case Node::Kind::NonObjCAttribute:
9799
case Node::Kind::PartialApplyObjCForwarder:
98100
case Node::Kind::PartialApplyForwarder:
101+
case Node::Kind::ReabstractionThunkHelper:
102+
case Node::Kind::ReabstractionThunk:
99103
case Node::Kind::ProtocolWitness:
100104
return true;
101105
default:
@@ -127,8 +131,10 @@ std::string Context::getThunkTarget(llvm::StringRef MangledName) {
127131
// TODO: remove this line as soon as MANGLING_PREFIX_STR gets "_S".
128132
|| MangledName.startswith("_S")) {
129133

130-
// The target of a protocol witness is not derivable from the mangling.
131-
if (MangledName.endswith("TW"))
134+
// The targets of those thunks not derivable from the mangling.
135+
if (MangledName.endswith("TR") ||
136+
MangledName.endswith("Tr") ||
137+
MangledName.endswith("TW") )
132138
return std::string();
133139

134140
return MangledName.substr(0, MangledName.size() - 2).str();

test/Demangle/Inputs/manglings.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,6 @@ _T0s13_UnicodeViewsVss22RandomAccessCollectionRzs0A8EncodingR_11SubSequence_5Ind
252252
_T010Foundation11MeasurementV12SimulatorKitSo9UnitAngleCRszlE11OrientationO2eeoiSbAcDEAGOyAF_G_AKtFZ ---> static (extension in SimulatorKit):Foundation.Measurement<A where A == __ObjC.UnitAngle>.Orientation.== infix((extension in SimulatorKit):Foundation.Measurement<__ObjC.UnitAngle>.Orientation, (extension in SimulatorKit):Foundation.Measurement<__ObjC.UnitAngle>.Orientation) -> Swift.Bool
253253
_T04main1_yyF ---> main._() -> ()
254254
_T04test6testitSiyt_tF ---> test.testit(()) -> Swift.Int
255-
_T08_ElementQzSbs5Error_pIxxdzo_ABSbsAC_pIxidzo_s26RangeReplaceableCollectionRzABRLClTR -> reabstraction thunk helper <A where A: Swift.RangeReplaceableCollection, A._Element: AnyObject> from @callee_owned (@owned A._Element) -> (@unowned Swift.Bool, @error @owned Swift.Error) to @callee_owned (@in A._Element) -> (@unowned Swift.Bool, @error @owned Swift.Error)
256-
255+
_T08_ElementQzSbs5Error_pIxxdzo_ABSbsAC_pIxidzo_s26RangeReplaceableCollectionRzABRLClTR ---> {T:} reabstraction thunk helper <A where A: Swift.RangeReplaceableCollection, A._Element: AnyObject> from @callee_owned (@owned A._Element) -> (@unowned Swift.Bool, @error @owned Swift.Error) to @callee_owned (@in A._Element) -> (@unowned Swift.Bool, @error @owned Swift.Error)
256+
_T0Ix_IyB_Tr ---> {T:} reabstraction thunk from @callee_owned () -> () to @callee_unowned @convention(block) () -> ()
257257

0 commit comments

Comments
 (0)