[Lldb-commits] [lldb] 7862728 - [lldb] Rewrite and extend TestConstThis
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 6 05:51:18 PDT 2021
Author: Raphael Isemann
Date: 2021-10-06T14:51:00+02:00
New Revision: 7862728cab1b7724d2adf0f0075a3289d87ec20c
URL: https://github.com/llvm/llvm-project/commit/7862728cab1b7724d2adf0f0075a3289d87ec20c
DIFF: https://github.com/llvm/llvm-project/commit/7862728cab1b7724d2adf0f0075a3289d87ec20c.diff
LOG: [lldb] Rewrite and extend TestConstThis
Added:
lldb/test/API/lang/cpp/const_this/Makefile
Modified:
lldb/test/API/lang/cpp/const_this/TestConstThis.py
lldb/test/API/lang/cpp/const_this/main.cpp
Removed:
################################################################################
diff --git a/lldb/test/API/lang/cpp/const_this/Makefile b/lldb/test/API/lang/cpp/const_this/Makefile
new file mode 100644
index 0000000000000..99998b20bcb05
--- /dev/null
+++ b/lldb/test/API/lang/cpp/const_this/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/lang/cpp/const_this/TestConstThis.py b/lldb/test/API/lang/cpp/const_this/TestConstThis.py
index f08c0dcbda983..b6790ff36f649 100644
--- a/lldb/test/API/lang/cpp/const_this/TestConstThis.py
+++ b/lldb/test/API/lang/cpp/const_this/TestConstThis.py
@@ -1,4 +1,62 @@
-from lldbsuite.test import lldbinline
-from lldbsuite.test import decorators
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
-lldbinline.MakeInlineTest(__file__, globals(), [])
+
+class TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def run_class_tests(self):
+ # Expression not referencing context class.
+ self.expect_expr("1 + 1", result_type="int", result_value="2")
+ # Referencing context class.
+ # FIXME: This and the expression below should return const types.
+ self.expect_expr("member", result_type="int", result_value="3")
+ # Check the type of context class.
+ self.expect_expr("this", result_type="ContextClass *")
+
+ def test_member_func(self):
+ self.build()
+ lldbutil.run_to_source_breakpoint(
+ self, "// break in function in class.", lldb.SBFileSpec("main.cpp")
+ )
+ self.run_class_tests()
+
+ def test_templated_member_func(self):
+ self.build()
+ lldbutil.run_to_source_breakpoint(
+ self,
+ "// break in templated function in class.",
+ lldb.SBFileSpec("main.cpp"),
+ )
+ self.run_class_tests()
+
+ def run_template_class_tests(self):
+ # Expression not referencing context class.
+ self.expect_expr("1 + 1", result_type="int", result_value="2")
+ # Referencing context class.
+ # FIXME: This and the expression below should return const types.
+ self.expect_expr("member", result_type="int", result_value="4")
+ # Check the type of context class.
+ self.expect_expr("this", result_type="TemplatedContextClass<int> *")
+
+ def test_template_member_func(self):
+ self.build()
+ lldbutil.run_to_source_breakpoint(
+ self,
+ "// break in function in templated class.",
+ lldb.SBFileSpec("main.cpp"),
+ )
+ self.run_template_class_tests()
+
+ def test_template_templated_member_func(self):
+ self.build()
+ lldbutil.run_to_source_breakpoint(
+ self,
+ "// break in templated function in templated class.",
+ lldb.SBFileSpec("main.cpp"),
+ )
+ self.run_template_class_tests()
diff --git a/lldb/test/API/lang/cpp/const_this/main.cpp b/lldb/test/API/lang/cpp/const_this/main.cpp
index 2db14e649918d..c9bd6a3f03bb2 100644
--- a/lldb/test/API/lang/cpp/const_this/main.cpp
+++ b/lldb/test/API/lang/cpp/const_this/main.cpp
@@ -1,12 +1,33 @@
-class foo {
-public:
- template <class T> T func(T x) const {
- return x+2; //% self.expect("expr 2+3", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["5"])
+struct ContextClass {
+ int member = 3;
+ ContextClass *this_type = nullptr;
+ ContextClass() { this_type = this; }
+
+ int func() const {
+ return member; // break in function in class.
+ }
+
+ template <class T> T templateFunc(T x) const {
+ return member; // break in templated function in class.
}
};
-int i;
+template <typename TC> struct TemplatedContextClass {
+ int member = 4;
+ TemplatedContextClass<TC> *this_type = nullptr;
+ TemplatedContextClass() { this_type = this; }
+
+ int func() const {
+ return member; // break in function in templated class.
+ }
+
+ template <class T> T templateFunc(T x) const {
+ return member; // break in templated function in templated class.
+ }
+};
int main() {
- return foo().func(i);
+ ContextClass c;
+ TemplatedContextClass<int> t;
+ return c.func() + c.templateFunc(1) + t.func() + t.templateFunc(1);
}
More information about the lldb-commits
mailing list