[Lldb-commits] [lldb] 65ac68e - [lldb] Add test for multiple inheritance
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 11 04:32:09 PST 2020
Author: Raphael Isemann
Date: 2020-02-11T13:31:34+01:00
New Revision: 65ac68ec3419abd98731e0c434229239e1563045
URL: https://github.com/llvm/llvm-project/commit/65ac68ec3419abd98731e0c434229239e1563045
DIFF: https://github.com/llvm/llvm-project/commit/65ac68ec3419abd98731e0c434229239e1563045.diff
LOG: [lldb] Add test for multiple inheritance
Added:
lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/Makefile
lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py
lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/main.cpp
Modified:
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/Makefile
new file mode 100644
index 000000000000..99998b20bcb0
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py
new file mode 100644
index 000000000000..defd4bd5df5f
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py
@@ -0,0 +1,35 @@
+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__)
+
+ def test(self):
+ self.build()
+ lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.cpp"))
+
+ # Member access
+ self.expect_expr("C.Base1::m_base", result_type="int", result_value="11")
+ self.expect_expr("C.Base2::m_base", result_type="int", result_value="12")
+ self.expect_expr("C.m1", result_type="int", result_value="22")
+ self.expect_expr("C.m2", result_type="int", result_value="33")
+ self.expect_expr("C.m_final", result_type="int", result_value="44")
+
+ # Virtual functions
+ self.expect_expr("C.Base1::virt_base()", result_type="int", result_value="111")
+ self.expect_expr("C.Base2::virt_base()", result_type="int", result_value="121")
+ self.expect_expr("C.virt1()", result_type="int", result_value="3")
+ self.expect_expr("C.virt2()", result_type="int", result_value="5")
+ self.expect_expr("C.final_virt()", result_type="int", result_value="7")
+ self.expect_expr("C.virt_common()", result_type="int", result_value="444")
+
+ # Normal functions
+ self.expect_expr("C.Base1::func_base()", result_type="int", result_value="112")
+ self.expect_expr("C.Base2::func_base()", result_type="int", result_value="122")
+ self.expect_expr("C.func1()", result_type="int", result_value="4")
+ self.expect_expr("C.func2()", result_type="int", result_value="6")
+ self.expect_expr("C.final_func()", result_type="int", result_value="8")
+ self.expect_expr("C.func_common()", result_type="int", result_value="888")
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/main.cpp
new file mode 100644
index 000000000000..62c40a52a150
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/multiple-inheritance/main.cpp
@@ -0,0 +1,52 @@
+struct CommonBase {
+ int m_base;
+ int virt_base_val;
+ int func_base_val;
+ virtual int virt_base() { return virt_base_val; }
+ virtual int virt_common() { return 555; }
+ int func_base() { return func_base_val; }
+ int func_common() { return 777; }
+};
+
+struct Base1 : CommonBase {
+ int m1 = 22;
+ Base1() {
+ // Give the base functions/members unique values.
+ virt_base_val = 111;
+ func_base_val = 112;
+ m_base = 11;
+ }
+ virtual int virt1() { return 3; }
+ int func1() { return 4; }
+};
+
+struct Base2 : CommonBase {
+ int m2 = 33;
+ Base2() {
+ // Give the base functions/members unique values.
+ virt_base_val = 121;
+ func_base_val = 122;
+ m_base = 12;
+ }
+ virtual int virt2() { return 5; }
+ int func2() { return 6; }
+};
+
+struct FinalClass : Base1, Base2 {
+ int m_final = 44;
+ virtual int final_virt() { return 7; }
+ int final_func() { return 8; }
+ virtual int virt_common() { return 444; }
+ int func_common() { return 888; }
+};
+
+int main() {
+ FinalClass C;
+ // Call functions so they get emitted.
+ C.func1();
+ C.func2();
+ C.final_func();
+ C.func_common();
+ C.Base1::func_base();
+ return 0; // break here
+}
More information about the lldb-commits
mailing list