Skip to content

Commit ad3e6b9

Browse files
committed
[SourceKit] Make sourcekitd-test -req=demangle STDIN mode actually work
This didn't work at all because it didn't advance cursor after regex matching. Align regex with swift-demangle.
1 parent e998858 commit ad3e6b9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,10 +1663,13 @@ static void prepareDemangleRequest(sourcekitd_object_t Req,
16631663
llvm::StringRef inputContents = input.get()->getBuffer();
16641664

16651665
// This doesn't handle Unicode symbols, but maybe that's okay.
1666-
llvm::Regex maybeSymbol("(_T|" MANGLING_PREFIX_STR ")[_a-zA-Z0-9$]+");
1666+
// Also accept the future mangling prefix.
1667+
llvm::Regex maybeSymbol("(_T|_?\\$[Ss])[_a-zA-Z0-9$.]+");
16671668
llvm::SmallVector<llvm::StringRef, 1> matches;
16681669
while (maybeSymbol.match(inputContents, &matches)) {
16691670
addName(matches.front());
1671+
auto offset = matches.front().data() - inputContents.data();
1672+
inputContents = inputContents.substr(offset + matches.front().size());
16701673
}
16711674

16721675
} else {

tools/swift-demangle/swift-demangle.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static void demangle(llvm::raw_ostream &os, llvm::StringRef name,
174174
static int demangleSTDIN(const swift::Demangle::DemangleOptions &options) {
175175
// This doesn't handle Unicode symbols, but maybe that's okay.
176176
// Also accept the future mangling prefix.
177-
// TODO: remove the "_S" as soon as MANGLING_PREFIX_STR gets "_S".
178177
llvm::Regex maybeSymbol("(_T|_?\\$[Ss])[_a-zA-Z0-9$.]+");
179178

180179
swift::Demangle::Context DCtx;

0 commit comments

Comments
 (0)