[Lldb-commits] [lldb] 3c66729 - [lldb][Test] Fix import-std-module and data-formatter tests on older compilers
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Thu Feb 2 03:35:17 PST 2023
Author: Michael Buch
Date: 2023-02-02T11:34:07Z
New Revision: 3c66729887d6113068025776994b4c49bd8e45e2
URL: https://github.com/llvm/llvm-project/commit/3c66729887d6113068025776994b4c49bd8e45e2
DIFF: https://github.com/llvm/llvm-project/commit/3c66729887d6113068025776994b4c49bd8e45e2.diff
LOG: [lldb][Test] Fix import-std-module and data-formatter tests on older compilers
Fixes API tests for older compilers.
Since https://reviews.llvm.org/D141828 defaulted
arguments will be omitted, but older Clang's won't.
Differential Revision: https://reviews.llvm.org/D143022
Added:
Modified:
lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py
lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py
lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py
lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
Removed:
################################################################################
diff --git a/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
index f77ba0d2417a4..f12f5f96aa5d6 100644
--- a/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
@@ -20,7 +20,11 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
- deque_type = "std::deque<int>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ deque_type = "std::deque<int>"
+ else:
+ deque_type = "std::deque<int, std::allocator<int> >"
+
size_type = "size_type"
value_type = "value_type"
iterator = "iterator"
diff --git a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
index cf2f63d6b669b..d62e49f11cbb2 100644
--- a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
@@ -21,7 +21,11 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
- deque_type = "std::deque<Foo>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ deque_type = "std::deque<Foo>"
+ else:
+ deque_type = "std::deque<Foo, std::allocator<Foo> >"
+
size_type = "size_type"
value_type = "value_type"
diff --git a/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
index d794f3b127b3a..ad6c5f487b9d4 100644
--- a/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
@@ -20,7 +20,11 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
- list_type = "std::forward_list<Foo>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ list_type = "std::forward_list<Foo>"
+ else:
+ list_type = "std::forward_list<Foo, std::allocator<Foo> >"
+
value_type = "value_type"
# FIXME: This has three elements in it but the formatter seems to
diff --git a/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
index 0b6ca835b0c89..8cb6c13865c95 100644
--- a/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
@@ -20,7 +20,11 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
- list_type = "std::forward_list<int>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ list_type = "std::forward_list<int>"
+ else:
+ list_type = "std::forward_list<int, std::allocator<int> >"
+
value_type = "value_type"
# FIXME: This has three elements in it but the formatter seems to
diff --git a/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
index 0c6d62a4267f9..e67ff4b947fd6 100644
--- a/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
@@ -22,7 +22,11 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
- list_type = "std::list<Foo>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ list_type = "std::list<Foo>"
+ else:
+ list_type = "std::list<Foo, std::allocator<Foo> >"
+
size_type = "size_type"
value_type = "value_type"
diff --git a/lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py
index fe496bc25f60b..b81e2c63e206e 100644
--- a/lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py
@@ -20,7 +20,11 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
- list_type = "std::list<int>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ list_type = "std::list<int>"
+ else:
+ list_type = "std::list<int, std::allocator<int> >"
+
size_type = "size_type"
value_type = "value_type"
diff --git a/lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py b/lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
index 3e8910a79e4be..8e3dca65b5671 100644
--- a/lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
+++ b/lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
@@ -31,13 +31,20 @@ def test(self):
ValueCheck(value="2"),
]
- vector_type = "std::vector<int>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ vector_type = "std::vector<int>"
+ dbg_vec_type = "std::vector<DbgInfoClass>"
+ module_vector_type = "std::vector<int>"
+ else:
+ vector_type = "std::vector<int, std::allocator<int> >"
+ dbg_vec_type = "std::vector<DbgInfoClass, std::allocator<DbgInfoClass> >"
+ module_vector_type = "std::vector<int>"
# First muddy the scratch AST with non-C++ module types.
self.expect_expr("a", result_type=vector_type,
result_children=children)
self.expect_expr("dbg_info_vec",
- result_type="std::vector<DbgInfoClass>",
+ result_type=dbg_vec_type,
result_children=[
ValueCheck(type="DbgInfoClass", children=[
ValueCheck(name="ints", type=vector_type, children=[
@@ -48,15 +55,15 @@ def test(self):
# Enable the C++ module import and get the module vector type.
self.runCmd("settings set target.import-std-module true")
- self.expect_expr("a", result_type=vector_type,
+ self.expect_expr("a", result_type=module_vector_type,
result_children=children)
# Test mixed debug info/module types
self.expect_expr("dbg_info_vec",
- result_type="std::vector<DbgInfoClass>",
+ result_type=dbg_vec_type,
result_children=[
ValueCheck(type="DbgInfoClass", children=[
- ValueCheck(name="ints", type=vector_type, children=[
+ ValueCheck(name="ints", type=module_vector_type, children=[
ValueCheck(value="1")
])
])
@@ -70,7 +77,7 @@ def test(self):
# Test the types that were previoiusly mixed debug info/module types.
self.expect_expr("dbg_info_vec",
- result_type="std::vector<DbgInfoClass>",
+ result_type=dbg_vec_type,
result_children=[
ValueCheck(type="DbgInfoClass", children=[
ValueCheck(name="ints", type=vector_type, children=[
diff --git a/lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py
index 634bd8fdc5c4f..d084083fd4c43 100644
--- a/lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py
@@ -20,7 +20,11 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
- queue_type = "std::queue<C>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ queue_type = "std::queue<C>"
+ else:
+ queue_type = "std::queue<C, std::deque<C, std::allocator<C> > >"
+
size_type = "size_type"
value_type = "value_type"
@@ -52,7 +56,11 @@ def test(self):
result_value="5")
# Test std::queue functionality with a std::list.
- queue_type = "std::queue<C, std::list<C> >"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ queue_type = "std::queue<C, std::list<C> >"
+ else:
+ queue_type = "std::queue<C, std::list<C, std::allocator<C> > >"
+
self.expect_expr(
"q_list",
result_type=queue_type,
diff --git a/lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py b/lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
index 670839a8f2143..7e6d6e0424cae 100644
--- a/lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
@@ -14,8 +14,13 @@ def test(self):
"// Set break point at this line.",
lldb.SBFileSpec("main.cpp"))
+ if self.expectedCompilerVersion(['>', '16.0']):
+ vec_type = "std::vector<int>"
+ else:
+ vec_type = "std::vector<int, std::allocator<int> >"
+
# Test printing the vector before enabling any C++ module setting.
- self.expect_expr("a", result_type="std::vector<int>")
+ self.expect_expr("a", result_type=vec_type)
# Set loading the import-std-module to 'fallback' which loads the module
# and retries when an expression fails to parse.
@@ -23,7 +28,7 @@ def test(self):
# Printing the vector still works. This should return the same type
# as before as this shouldn't use a C++ module type.
- self.expect_expr("a", result_type="std::vector<int>")
+ self.expect_expr("a", result_type=vec_type)
# This expression can only parse with a C++ module. LLDB should
# automatically fall back to import the C++ module to get this working.
diff --git a/lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py b/lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
index c32c971e66a83..3a219d9b43e93 100644
--- a/lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
+++ b/lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
@@ -22,9 +22,14 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
+ if self.expectedCompilerVersion(['>', '16.0']):
+ ptr_type = "std::unique_ptr<Foo>"
+ else:
+ ptr_type = "std::unique_ptr<Foo, std::default_delete<Foo> >"
+
self.expect_expr(
"s",
- result_type="std::unique_ptr<Foo>",
+ result_type=ptr_type,
result_children=[ValueCheck(children=[ValueCheck(value="3")])])
self.expect_expr("s->a", result_type="int", result_value="3")
self.expect_expr("s->a = 5", result_type="int", result_value="5")
diff --git a/lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py
index 6775a53e39e3b..01ee90b5357f3 100644
--- a/lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py
@@ -22,9 +22,14 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
+ if self.expectedCompilerVersion(['>', '16.0']):
+ ptr_type = "std::unique_ptr<int>"
+ else:
+ ptr_type = "std::unique_ptr<int, std::default_delete<int> >"
+
self.expect_expr(
"s",
- result_type="std::unique_ptr<int>",
+ result_type=ptr_type,
result_summary="3",
result_children=[ValueCheck(name="__value_")])
self.expect_expr("*s", result_type="int", result_value="3")
diff --git a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
index c4cfedb5e597d..6a411d7d39fb4 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
@@ -22,7 +22,11 @@ def test(self):
self.runCmd("settings set target.import-std-module true")
- vector_type = "std::vector<Foo>"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ vector_type = "std::vector<Foo>"
+ else:
+ vector_type = "std::vector<Foo, std::allocator<Foo> >"
+
size_type = "size_type"
value_type = "value_type"
iterator = "iterator"
diff --git a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
index d843ced39c802..4adc25385f761 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
@@ -18,8 +18,13 @@ def test(self):
"// Set break point at this line.",
lldb.SBFileSpec("main.cpp"))
- vector_type = "std::vector<int>"
- vector_of_vector_type = "std::vector<" + vector_type + " >"
+ if self.expectedCompilerVersion(['>', '16.0']):
+ vector_type = "std::vector<int>"
+ vector_of_vector_type = "std::vector<std::vector<int> >"
+ else:
+ vector_type = "std::vector<int>"
+ vector_of_vector_type = "std::vector<std::vector<int>, std::allocator<std::vector<int> > >"
+
size_type = "size_type"
value_type = "value_type"
@@ -29,13 +34,13 @@ def test(self):
"a",
result_type=vector_of_vector_type,
result_children=[
- ValueCheck(type="std::vector<int>",
+ ValueCheck(type=vector_type,
children=[
ValueCheck(value='1'),
ValueCheck(value='2'),
ValueCheck(value='3'),
]),
- ValueCheck(type="std::vector<int>",
+ ValueCheck(type=vector_type,
children=[
ValueCheck(value='3'),
ValueCheck(value='2'),
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
index b20ac521c7c32..c8cf41bf062dd 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
@@ -58,9 +58,14 @@ def test_shared_ptr_variables(self):
self.assertRegex(valobj.summary, r"^10( strong=1)? weak=1$")
self.assertNotEqual(valobj.child[0].unsigned, 0)
+ if self.expectedCompilerVersion(['>', '16.0']):
+ string_type = "std::basic_string<char>"
+ else:
+ string_type = "std::basic_string<char, std::char_traits<char>, std::allocator<char> >"
+
valobj = self.expect_var_path(
"sp_str",
- type="std::shared_ptr<std::basic_string<char> >",
+ type="std::shared_ptr<" + string_type + " >",
children=[ValueCheck(name="__ptr_", summary='"hello"')],
)
self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=1$')
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
index 7ac0efb4ca742..d9803f4b0b675 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -51,6 +51,13 @@ def cleanup():
self.addTearDownHook(cleanup)
ns = self.namespace
+
+ if self.expectedCompilerVersion(['>', '16.0']):
+ expected_basic_string = '%s::basic_string<unsigned char>'%ns
+ else:
+ expected_basic_string = '%s::basic_string<unsigned char, %s::char_traits<unsigned char>, ' \
+ '%s::allocator<unsigned char> >'%(ns,ns,ns)
+
self.expect(
"frame variable",
substrs=[
@@ -70,7 +77,7 @@ def cleanup():
'(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns,
# FIXME: This should have a 'U' prefix.
'(%s::u32string) u32_empty = ""'%ns,
- '(%s::basic_string<unsigned char>) uchar = "aaaaa"'%(ns),
+ '(%s) uchar = "aaaaa"'%expected_basic_string,
'(%s::string *) null_str = nullptr'%ns,
])
@@ -107,7 +114,7 @@ def cleanup():
'(%s::u16string) u16_string = u"ß水氶"'%ns,
'(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns,
'(%s::u32string) u32_empty = ""'%ns,
- '(%s::basic_string<unsigned char>) uchar = "aaaaa"'%(ns),
+ '(%s) uchar = "aaaaa"'%expected_basic_string,
'(%s::string *) null_str = nullptr'%ns,
])
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
index 7ebfabcf5fd69..4e5fcd12ebdda 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
@@ -56,6 +56,13 @@ def cleanup():
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
+ if self.expectedCompilerVersion(['>', '16.0']):
+ expected_basic_string = 'std::basic_string<unsigned char>'
+ expected_basic_string_view = 'std::basic_string_view<unsigned char>'
+ else:
+ expected_basic_string = 'std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >'
+ expected_basic_string_view = 'std::basic_string_view<unsigned char, std::char_traits<unsigned char> >'
+
self.expect_var_path('wempty',
type='std::wstring_view',
summary='L""')
@@ -96,10 +103,10 @@ def cleanup():
type='std::u32string_view',
summary='""')
self.expect_var_path('uchar_source',
- type='std::basic_string<unsigned char>',
+ type=expected_basic_string,
summary='"aaaaaaaaaa"')
self.expect_var_path('uchar',
- type='std::basic_string_view<unsigned char>',
+ type=expected_basic_string_view,
summary='"aaaaa"')
self.expect_var_path('oops',
type='std::string_view',
@@ -172,10 +179,10 @@ def cleanup():
type='std::u32string_view',
summary='""')
self.expect_var_path('uchar_source',
- type='std::basic_string<unsigned char>',
+ type=expected_basic_string,
summary='"aaaaaaaaaa"')
self.expect_var_path('uchar',
- type='std::basic_string_view<unsigned char>',
+ type=expected_basic_string_view,
summary='"aaaaa"')
self.runCmd('cont')
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
index a0d12b4f2061d..d9e18859e620a 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -11,6 +11,22 @@
class TestCase(TestBase):
+ def make_expected_type(self, pointee_type: str, qualifiers: str = "") -> str:
+ if qualifiers:
+ qualifiers = ' ' + qualifiers
+
+ if self.expectedCompilerVersion(['>', '16.0']):
+ return f'std::unique_ptr<{pointee_type}>{qualifiers}'
+ else:
+ return f'std::unique_ptr<{pointee_type}, std::default_delete<{pointee_type}> >{qualifiers}'
+
+ def make_expected_basic_string_ptr(self) -> str:
+ if self.expectedCompilerVersion(['>', '16.0']):
+ return f'std::unique_ptr<std::basic_string<char> >'
+ else:
+ return 'std::unique_ptr<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ' \
+ 'std::default_delete<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >'
+
@add_test_categories(["libc++"])
def test_unique_ptr_variables(self):
"""Test `frame variable` output for `std::unique_ptr` types."""
@@ -22,7 +38,7 @@ def test_unique_ptr_variables(self):
valobj = self.expect_var_path(
"up_empty",
- type="std::unique_ptr<int>",
+ type=self.make_expected_type("int"),
summary="nullptr",
children=[ValueCheck(name="__value_")],
)
@@ -36,7 +52,7 @@ def test_unique_ptr_variables(self):
valobj = self.expect_var_path(
"up_int",
- type="std::unique_ptr<int>",
+ type=self.make_expected_type("int"),
summary="10",
children=[ValueCheck(name="__value_")],
)
@@ -44,7 +60,7 @@ def test_unique_ptr_variables(self):
valobj = self.expect_var_path(
"up_int_ref",
- type="std::unique_ptr<int> &",
+ type=self.make_expected_type("int", qualifiers="&"),
summary="10",
children=[ValueCheck(name="__value_")],
)
@@ -52,7 +68,7 @@ def test_unique_ptr_variables(self):
valobj = self.expect_var_path(
"up_int_ref_ref",
- type="std::unique_ptr<int> &&",
+ type=self.make_expected_type("int", qualifiers="&&"),
summary="10",
children=[ValueCheck(name="__value_")],
)
@@ -60,13 +76,13 @@ def test_unique_ptr_variables(self):
valobj = self.expect_var_path(
"up_str",
- type="std::unique_ptr<std::basic_string<char> >",
+ type=self.make_expected_basic_string_ptr(),
summary='"hello"',
children=[ValueCheck(name="__value_", summary='"hello"')],
)
valobj = self.expect_var_path(
- "up_user", type="std::unique_ptr<User>"
+ "up_user", type=self.make_expected_type("User")
)
self.assertRegex(valobj.summary, "^User @ 0x0*[1-9a-f][0-9a-f]+$")
self.assertNotEqual(valobj.child[0].unsigned, 0)
More information about the lldb-commits
mailing list