Skip to content

Commit 977610f

Browse files
committed
[lldb] Delete unreachable(ish) code (NFCish)
No test in the testsuite triggeres this code path, except for the new ValueGeneric tes, which triggers it for entirely the wrong reason. I added a new test that exercises the case that is mentioned in the comment to make sure that this is indeed obsolete.
1 parent fe24ba0 commit 977610f

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3768,17 +3768,6 @@ TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
37683768
if (llvm::StringRef(AsMangledName(type))
37693769
.ends_with("sSo18NSNotificationNameaD"))
37703770
return GetTypeFromMangledTypename(ConstString("$sSo8NSStringCD"));
3771-
if (result->GetMangledTypeName().GetStringRef().count('$') > 1 &&
3772-
get_ast_num_children() ==
3773-
llvm::expectedToStdOptional(runtime->GetNumChildren(
3774-
{weak_from_this(), type}, exe_scope)))
3775-
// If available, prefer the AST for private types. Private
3776-
// identifiers are not ABI; the runtime returns anonymous private
3777-
// identifiers (using a '$' prefix) which cannot match identifiers
3778-
// in the AST. Because these private types can't be used in an AST
3779-
// context, prefer the AST type if available.
3780-
if (auto ast_type = fallback())
3781-
return ast_type;
37823771
return result;
37833772
}
37843773
if (!result)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SWIFT_SOURCES := main.swift
2+
include Makefile.rules
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
import lldbsuite.test.lldbutil as lldbutil
5+
6+
class TestSwiftPrivateMember(TestBase):
7+
8+
@skipUnlessDarwin
9+
@swiftTest
10+
def test(self):
11+
self.build()
12+
13+
target, process, thread, _ = lldbutil.run_to_source_breakpoint(
14+
self, "break here", lldb.SBFileSpec('main.swift'))
15+
frame = thread.frames[0]
16+
x = frame.FindVariable("x")
17+
member = x.GetChildAtIndex(0)
18+
self.assertIn("23", str(member))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fileprivate struct U {
2+
let i = 23
3+
}
4+
5+
fileprivate struct V {
6+
let member = U()
7+
}
8+
9+
func main() {
10+
let x = V()
11+
print(x) // break here
12+
}
13+
14+
main()

0 commit comments

Comments
 (0)