Skip to content

Commit ecd177f

Browse files
committed
Demangler: handle suffixes in the form '.<n>'.
Demangle such suffixes as "unmangled suffix" IRGen still uses '.<n>' to disambiguate partial apply thunks and outlined copy functions. rdar://problem/32934962
1 parent df26c47 commit ecd177f

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

include/swift/Demangling/Demangler.h

+6
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ class Demangler : public NodeFactory {
328328
Pos--;
329329
}
330330

331+
StringRef consumeAll() {
332+
StringRef str = Text.drop_front(Pos);
333+
Pos = Text.size();
334+
return str;
335+
}
336+
331337
void pushNode(NodePointer Nd) {
332338
NodeStack.push_back(Nd, *this);
333339
}

lib/Demangling/Demangler.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,11 @@ NodePointer Demangler::demangleOperator() {
418418
case 'z': return createType(createWithChild(Node::Kind::InOut,
419419
popTypeAndGetChild()));
420420
case '_': return createNode(Node::Kind::FirstElementMarker);
421+
case '.':
422+
// IRGen still uses '.<n>' to disambiguate partial apply thunks and
423+
// outlined copy functions. We treat such a suffix as "unmangled suffix".
424+
pushBack();
425+
return createNode(Node::Kind::Suffix, consumeAll());
421426
default:
422427
pushBack();
423428
return demangleIdentifier();

test/Demangle/Inputs/manglings.txt

+2
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,5 @@ _T0A8 ---> _T0A8
264264
_T0s30ReversedRandomAccessCollectionVyxGTfq3nnpf_nTfq1cn_nTfq4x_n ---> _T0s30ReversedRandomAccessCollectionVyxGTfq3nnpf_nTfq1cn_nTfq4x_n
265265
_T03abc6testitySiFTm ---> merged abc.testit(Swift.Int) -> ()
266266
_T04main4TestCACSi1x_tc6_PRIV_Llfc ---> main.Test.(in _PRIV_).init(x: Swift.Int) -> main.Test
267+
_T0SqWy.17 ---> outlined copy of Swift.Optional with unmangled suffix ".17"
268+

tools/swift-demangle/swift-demangle.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int demangleSTDIN(const swift::Demangle::DemangleOptions &options) {
166166
// This doesn't handle Unicode symbols, but maybe that's okay.
167167
// Also accept the future mangling prefix.
168168
// TODO: remove the "_S" as soon as MANGLING_PREFIX_STR gets "_S".
169-
llvm::Regex maybeSymbol("(_T|_*\\$S|" MANGLING_PREFIX_STR ")[_a-zA-Z0-9$]+");
169+
llvm::Regex maybeSymbol("(_T|_*\\$S|" MANGLING_PREFIX_STR ")[_a-zA-Z0-9$.]+");
170170

171171
swift::Demangle::Context DCtx;
172172
for (std::string mangled; std::getline(std::cin, mangled);) {

0 commit comments

Comments
 (0)