Skip to content

Commit 9d8ccbc

Browse files
authored
[lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types (#87807)
Depends on #87767
1 parent f4e3226 commit 9d8ccbc

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def setUp(self):
1313
# Find the line numbers to break inside main().
1414
self.main_source = "main.cpp"
1515
self.break_line = line_number(self.main_source, "// Set breakpoint here.")
16+
self.bar_break_line = line_number(self.main_source, "return id + Class")
1617

1718
@add_test_categories(["pyapi"])
1819
def test_with_python_api(self):
@@ -26,6 +27,11 @@ def test_with_python_api(self):
2627
bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line)
2728
self.assertTrue(bpt, VALID_BREAKPOINT)
2829

30+
bar_bpt = target.BreakpointCreateByLocation(
31+
self.main_source, self.bar_break_line
32+
)
33+
self.assertTrue(bar_bpt, VALID_BREAKPOINT)
34+
2935
# Now launch the process, and do not stop at entry point.
3036
process = target.LaunchSimple(None, None, self.get_process_working_directory())
3137

@@ -52,3 +58,10 @@ def test_with_python_api(self):
5258
patterns=["\(id\) \$.* = nil"],
5359
)
5460
self.expect("expr --language C++ -- id my_id = 0; my_id", error=True)
61+
62+
lldbutil.continue_to_breakpoint(process, bar_bpt)
63+
64+
self.expect_expr("id", result_value="12", result_type="int")
65+
self.expect_expr("Class", result_value="15", result_type="int")
66+
self.expect("expr --language Objective-C++ -- id", error=True)
67+
self.expect("expr --language Objective-C++ -- Class", error=True)

lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ namespace ns {
22
typedef int id;
33
};
44

5+
int bar() {
6+
int id = 12;
7+
int Class = 15;
8+
return id + Class;
9+
}
10+
511
int main()
612
{
713
ns::id foo = 0;
8-
return foo; // Set breakpoint here.
14+
return foo + bar(); // Set breakpoint here.
915
}

0 commit comments

Comments
 (0)