https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/87807
>From 734e127b758b00210aa508c84d0222165c036ac4 Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Fri, 5 Apr 2024 12:10:09 +0100 Subject: [PATCH 1/2] [lldb][test] Add tests for evaluating local variables whose name clashes with Objective-C types Depends on https://github.com/llvm/llvm-project/pull/87767 --- .../objc-builtin-types/TestObjCBuiltinTypes.py | 13 +++++++++++++ .../API/lang/objcxx/objc-builtin-types/main.cpp | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py index 611c7388999058..19ae2f091bdd5e 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py @@ -13,6 +13,7 @@ def setUp(self): # Find the line numbers to break inside main(). self.main_source = "main.cpp" self.break_line = line_number(self.main_source, "// Set breakpoint here.") + self.bar_break_line = line_number(self.main_source, "return id + Class") @add_test_categories(["pyapi"]) def test_with_python_api(self): @@ -26,6 +27,11 @@ def test_with_python_api(self): bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line) self.assertTrue(bpt, VALID_BREAKPOINT) + bar_bpt = target.BreakpointCreateByLocation( + self.main_source, self.bar_break_line + ) + self.assertTrue(bar_bpt, VALID_BREAKPOINT) + # Now launch the process, and do not stop at entry point. process = target.LaunchSimple(None, None, self.get_process_working_directory()) @@ -52,3 +58,10 @@ def test_with_python_api(self): patterns=["\(id\) \$.* = nil"], ) self.expect("expr --language C++ -- id my_id = 0; my_id", error=True) + + lldbutil.continue_to_breakpoint(process, bar_bpt) + + self.expect_expr("id", result_value="12", result_type="int") + self.expect_expr("Class", result_value="15", result_type="int") + self.expect("expr --language C++ -- id", error=True) + self.expect("expr --language C++ -- Class", error=True) diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp index 6dd8cbc6e9fef6..5b35ec0f0b8c98 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/main.cpp @@ -2,8 +2,14 @@ namespace ns { typedef int id; }; +int bar() { + int id = 12; + int Class = 15; + return id + Class; +} + int main() { ns::id foo = 0; - return foo; // Set breakpoint here. + return foo + bar(); // Set breakpoint here. } >From 081c72dd4d61279a999fb70e8aefd289a327de3f Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Fri, 12 Apr 2024 16:03:41 +0200 Subject: [PATCH 2/2] fixup! fix test --- .../lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py index 19ae2f091bdd5e..3cdca31b8969bd 100644 --- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py @@ -63,5 +63,5 @@ def test_with_python_api(self): self.expect_expr("id", result_value="12", result_type="int") self.expect_expr("Class", result_value="15", result_type="int") - self.expect("expr --language C++ -- id", error=True) - self.expect("expr --language C++ -- Class", error=True) + self.expect("expr --language Objective-C++ -- id", error=True) + self.expect("expr --language Objective-C++ -- Class", error=True) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits