Skip to content

Commit 7208b18

Browse files
committed
Mangling: support the new mangling prefix in various prefix checks
1 parent c675395 commit 7208b18

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/SwiftDemangle/SwiftDemangle.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
//===----------------------------------------------------------------------===//
1717

1818
#include "swift/Basic/DemangleWrappers.h"
19+
#include "swift/Basic/ManglingMacros.h"
1920
#include "swift/SwiftDemangle/SwiftDemangle.h"
2021

2122
/// \returns true if \p MangledName starts with Swift prefix, "_T".
2223
static bool isSwiftPrefixed(const char *MangledName) {
23-
return (MangledName[0] == '_' && MangledName[1] == 'T');
24+
return MangledName[0] == '_' &&
25+
(MangledName[1] == 'T' || MangledName[1] == MANGLING_PREFIX_STR[1]);
2426
}
2527

2628
static size_t swift_demangle_getDemangledName_Options(const char *MangledName,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "TestOptions.h"
1616
#include "SourceKit/Support/Concurrency.h"
1717
#include "clang/Rewrite/Core/RewriteBuffer.h"
18+
#include "swift/Basic/ManglingMacros.h"
1819
#include "llvm/ADT/ArrayRef.h"
1920
#include "llvm/ADT/Optional.h"
2021
#include "llvm/ADT/StringSwitch.h"
@@ -1344,7 +1345,7 @@ static void prepareDemangleRequest(sourcekitd_object_t Req,
13441345
llvm::StringRef inputContents = input.get()->getBuffer();
13451346

13461347
// This doesn't handle Unicode symbols, but maybe that's okay.
1347-
llvm::Regex maybeSymbol("_T[_a-zA-Z0-9$]+");
1348+
llvm::Regex maybeSymbol("(_T|" MANGLING_PREFIX_STR ")[_a-zA-Z0-9$]+");
13481349
llvm::SmallVector<llvm::StringRef, 1> matches;
13491350
while (maybeSymbol.match(inputContents, &matches)) {
13501351
addName(matches.front());

tools/SourceKit/tools/sourcekitd/lib/API/Requests.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,8 @@ class SKDocConsumer : public DocInfoConsumer {
10471047
static bool isSwiftPrefixed(StringRef MangledName) {
10481048
if (MangledName.size() < 2)
10491049
return false;
1050-
return (MangledName[0] == '_' && MangledName[1] == 'T');
1050+
return MangledName[0] == '_' &&
1051+
(MangledName[1] == 'T' || MangledName[1] == MANGLING_PREFIX_STR[1]);
10511052
}
10521053

10531054
static sourcekitd_response_t demangleNames(ArrayRef<const char *> MangledNames,

0 commit comments

Comments
 (0)