[Lldb-commits] [lldb] 69e7b74 - [lldb][NFC] Add a test case for Objective-C properties with conflicting names
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 29 03:33:24 PDT 2021
Author: Raphael Isemann
Date: 2021-03-29T12:33:07+02:00
New Revision: 69e7b7457809bac02f3e6f7d643c4fb516b31616
URL: https://github.com/llvm/llvm-project/commit/69e7b7457809bac02f3e6f7d643c4fb516b31616
DIFF: https://github.com/llvm/llvm-project/commit/69e7b7457809bac02f3e6f7d643c4fb516b31616.diff
LOG: [lldb][NFC] Add a test case for Objective-C properties with conflicting names
This is an LLDB test for the ASTImporter crash that got fixed in D99077.
The test is using Clang modules for the properties as it seems the conflicting
names are not actually correctly handled when generating debug information
(only the first property is emitted and the second one is ignored in the current
clang ToT).
Added:
lldb/test/API/lang/objc/modules-objc-property/Makefile
lldb/test/API/lang/objc/modules-objc-property/TestModulesObjCProperty.py
lldb/test/API/lang/objc/modules-objc-property/main.m
lldb/test/API/lang/objc/modules-objc-property/module.modulemap
lldb/test/API/lang/objc/modules-objc-property/myModule.h
Modified:
Removed:
################################################################################
diff --git a/lldb/test/API/lang/objc/modules-objc-property/Makefile b/lldb/test/API/lang/objc/modules-objc-property/Makefile
new file mode 100644
index 000000000000..c7c990e73158
--- /dev/null
+++ b/lldb/test/API/lang/objc/modules-objc-property/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS = $(MANDATORY_MODULE_BUILD_CFLAGS) -I$(BUILDDIR)
+
+include Makefile.rules
diff --git a/lldb/test/API/lang/objc/modules-objc-property/TestModulesObjCProperty.py b/lldb/test/API/lang/objc/modules-objc-property/TestModulesObjCProperty.py
new file mode 100644
index 000000000000..d23949fe30b4
--- /dev/null
+++ b/lldb/test/API/lang/objc/modules-objc-property/TestModulesObjCProperty.py
@@ -0,0 +1,27 @@
+import unittest2
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @no_debug_info_test
+ def test_conflicting_properties(self):
+ """ Tests receiving two properties with the same name from modules."""
+ self.build()
+ lldbutil.run_to_source_breakpoint(
+ self, '// Set breakpoint here.', lldb.SBFileSpec('main.m'))
+
+ self.runCmd(
+ "settings set target.clang-module-search-paths \"" +
+ self.getSourceDir() +
+ "\"")
+
+ self.runCmd("expr @import myModule")
+ self.expect_expr("m.propConflict", result_value="5")
+ self.expect_expr("MyClass.propConflict", result_value="6")
diff --git a/lldb/test/API/lang/objc/modules-objc-property/main.m b/lldb/test/API/lang/objc/modules-objc-property/main.m
new file mode 100644
index 000000000000..c0f58f41b764
--- /dev/null
+++ b/lldb/test/API/lang/objc/modules-objc-property/main.m
@@ -0,0 +1,8 @@
+ at import Foundation;
+ at import myModule;
+
+int main() {
+ MyClass *m = [[MyClass alloc] init];
+ int i = m.propConflict + MyClass.propConflict;
+ return i; // Set breakpoint here.
+}
diff --git a/lldb/test/API/lang/objc/modules-objc-property/module.modulemap b/lldb/test/API/lang/objc/modules-objc-property/module.modulemap
new file mode 100644
index 000000000000..2ef8064d15b4
--- /dev/null
+++ b/lldb/test/API/lang/objc/modules-objc-property/module.modulemap
@@ -0,0 +1,4 @@
+module myModule {
+ header "myModule.h"
+ export *
+}
diff --git a/lldb/test/API/lang/objc/modules-objc-property/myModule.h b/lldb/test/API/lang/objc/modules-objc-property/myModule.h
new file mode 100644
index 000000000000..07b40ccc2f65
--- /dev/null
+++ b/lldb/test/API/lang/objc/modules-objc-property/myModule.h
@@ -0,0 +1,24 @@
+#ifndef MYMODULE
+#define MYMODULE
+
+ at import Foundation;
+
+ at interface MyClass : NSObject
+- (int) propConflict;
++ (int) propConflict;
+ at property(readonly) int propConflict;
+ at property(readonly,class) int propConflict;
+ at end
+
+ at implementation MyClass
+- (int) propConflict
+{
+ return 5;
+}
++ (int) propConflict
+{
+ return 6;
+}
+ at end
+
+#endif // MYMODULE
More information about the lldb-commits
mailing list