Michael137 created this revision. Herald added a project: All. Michael137 requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
Fixes API tests for older compilers. Since https://reviews.llvm.org/D141828 defaulted arguments will be omitted, but older Clang's won't. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D143022 Files: 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
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py =================================================================== --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py +++ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.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/string_view/TestDataFormatterLibcxxStringView.py @@ -56,6 +56,13 @@ # 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 @@ 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 @@ 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') Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.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/TestDataFormatterLibcxxString.py @@ -51,6 +51,13 @@ 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 @@ '(%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 @@ '(%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, ]) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.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/shared_ptr/TestDataFormatterLibcxxSharedPtr.py @@ -58,9 +58,14 @@ 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$') Index: lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py @@ -18,8 +18,12 @@ "// 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>" + 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 +33,13 @@ "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'), Index: lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py @@ -22,7 +22,11 @@ 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" Index: lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py @@ -22,9 +22,14 @@ 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") Index: 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-dbg-info-content/TestUniquePtrDbgInfoContent.py +++ lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py @@ -22,9 +22,14 @@ 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") Index: lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py +++ lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py @@ -14,8 +14,13 @@ "// 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 @@ # 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. Index: lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py @@ -20,7 +20,11 @@ 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 @@ 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, Index: lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py +++ lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py @@ -31,13 +31,20 @@ 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 @@ # 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 @@ # 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=[ Index: lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py @@ -20,7 +20,11 @@ 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" Index: lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py @@ -22,7 +22,11 @@ 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" Index: lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py @@ -20,7 +20,11 @@ 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 Index: 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-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py @@ -20,7 +20,11 @@ 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 Index: lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py @@ -21,7 +21,11 @@ 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" Index: lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py =================================================================== --- lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py +++ lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py @@ -20,7 +20,11 @@ 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"
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits