Skip to content

[lldb] Prevent IsSwiftMangledName false positives #3984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,15 @@ bool SwiftLanguageRuntime::IsSymbolARuntimeThunk(const Symbol &symbol) {
}

bool SwiftLanguageRuntime::IsSwiftMangledName(llvm::StringRef name) {
// Old-style mangling uses a "_T" prefix. This can lead to false positives
// with other symbols that just so happen to start with "_T". To prevent this,
// only return true for select old-style mangled names. The known cases to are
// ObjC classes and protocols. Classes are prefixed with either "_TtC" or
// "_TtGC" (generic classes). Protocols are prefixed with "_TtP". Other "_T"
// prefixed symbols are not considered to be Swift symbols.
if (name.startswith("_T"))
return name.startswith("_TtC") || name.startswith("_TtGC") ||
name.startswith("_TtP");
return swift::Demangle::isSwiftSymbol(name);
}

Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/lang/swift/printdecl/TestSwiftTypeLookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_swift_type_lookup(self):

# check that mangled name lookup works
self.expect(
'type lookup _TtSi',
'type lookup _$sSiD',
substrs=[
'struct Int',
'extension Swift.Int'])
Expand Down