From 1efde67d990c198b1480b2ab7b820f86388b84da Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 27 Jan 2023 11:13:31 +0000 Subject: [PATCH] Revert "[lldb] Add support for DW_AT_default_value in template params" This reverts commit 1cf52e540242f968e0cf789587bcf76c01332aeb. Due to test failures on Arm and AArch64 bots: https://lab.llvm.org/buildbot/#/builders/96/builds/34718 (which were obscured by an earlier build failure) --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 16 +- .../shared_ptr/TestDataFormatterLibcxxSharedPtr.py | 2 +- .../libcxx/string/TestDataFormatterLibcxxString.py | 6 +- .../TestDataFormatterLibcxxStringView.py | 8 +- .../unique_ptr/TestDataFormatterLibcxxUniquePtr.py | 12 +- lldb/unittests/SymbolFile/DWARF/CMakeLists.txt | 3 +- .../SymbolFile/DWARF/DWARFASTParserClangTests.cpp | 62 +--- .../DWARF/Inputs/DW_AT_default_value-test.yaml | 314 --------------------- 8 files changed, 21 insertions(+), 402 deletions(-) delete mode 100644 lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 4429b4f..49c8fae 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2003,7 +2003,6 @@ bool DWARFASTParserClang::ParseTemplateDIE( CompilerType clang_type; uint64_t uval64 = 0; bool uval64_valid = false; - bool is_default_template_arg = false; if (num_attributes > 0) { DWARFFormValue form_value; for (size_t i = 0; i < num_attributes; ++i) { @@ -2034,10 +2033,6 @@ bool DWARFASTParserClang::ParseTemplateDIE( uval64 = form_value.Unsigned(); } break; - case DW_AT_default_value: - if (attributes.ExtractFormValueAtIndex(i, form_value)) - is_default_template_arg = form_value.Boolean(); - break; default: break; } @@ -2063,19 +2058,16 @@ bool DWARFASTParserClang::ParseTemplateDIE( template_param_infos.InsertArg( name, clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed), - ClangUtil::GetQualType(clang_type), - is_default_template_arg)); + ClangUtil::GetQualType(clang_type))); } else { template_param_infos.InsertArg( - name, clang::TemplateArgument(ClangUtil::GetQualType(clang_type), - /*isNullPtr*/ false, - is_default_template_arg)); + name, + clang::TemplateArgument(ClangUtil::GetQualType(clang_type))); } } else { auto *tplt_type = m_ast.CreateTemplateTemplateParmDecl(template_name); template_param_infos.InsertArg( - name, clang::TemplateArgument(clang::TemplateName(tplt_type), - is_default_template_arg)); + name, clang::TemplateArgument(clang::TemplateName(tplt_type))); } } } 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 b20ac52..c646fcc 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 @@ -60,7 +60,7 @@ class TestCase(TestBase): valobj = self.expect_var_path( "sp_str", - type="std::shared_ptr >", + type="std::shared_ptr, std::allocator > >", 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 7ac0efb..07b1aff 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 @@ -70,7 +70,8 @@ class LibcxxStringDataFormatterTestCase(TestBase): '(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns, # FIXME: This should have a 'U' prefix. '(%s::u32string) u32_empty = ""'%ns, - '(%s::basic_string) uchar = "aaaaa"'%(ns), + '(%s::basic_string, ' + '%s::allocator >) uchar = "aaaaa"'%(ns,ns,ns), '(%s::string *) null_str = nullptr'%ns, ]) @@ -107,7 +108,8 @@ class LibcxxStringDataFormatterTestCase(TestBase): '(%s::u16string) u16_string = u"ß水氶"'%ns, '(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns, '(%s::u32string) u32_empty = ""'%ns, - '(%s::basic_string) uchar = "aaaaa"'%(ns), + '(%s::basic_string, ' + '%s::allocator >) uchar = "aaaaa"'%(ns,ns,ns), '(%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 7ebfabc..db82e7c 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 @@ -96,10 +96,10 @@ class LibcxxStringViewDataFormatterTestCase(TestBase): type='std::u32string_view', summary='""') self.expect_var_path('uchar_source', - type='std::basic_string', + type='std::basic_string, std::allocator >', summary='"aaaaaaaaaa"') self.expect_var_path('uchar', - type='std::basic_string_view', + type='std::basic_string_view >', summary='"aaaaa"') self.expect_var_path('oops', type='std::string_view', @@ -172,10 +172,10 @@ class LibcxxStringViewDataFormatterTestCase(TestBase): type='std::u32string_view', summary='""') self.expect_var_path('uchar_source', - type='std::basic_string', + type='std::basic_string, std::allocator >', summary='"aaaaaaaaaa"') self.expect_var_path('uchar', - type='std::basic_string_view', + type='std::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 a0d12b4..70efdd8 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 @@ -22,7 +22,7 @@ class TestCase(TestBase): valobj = self.expect_var_path( "up_empty", - type="std::unique_ptr", + type="std::unique_ptr >", summary="nullptr", children=[ValueCheck(name="__value_")], ) @@ -36,7 +36,7 @@ class TestCase(TestBase): valobj = self.expect_var_path( "up_int", - type="std::unique_ptr", + type="std::unique_ptr >", summary="10", children=[ValueCheck(name="__value_")], ) @@ -44,7 +44,7 @@ class TestCase(TestBase): valobj = self.expect_var_path( "up_int_ref", - type="std::unique_ptr &", + type="std::unique_ptr > &", summary="10", children=[ValueCheck(name="__value_")], ) @@ -52,7 +52,7 @@ class TestCase(TestBase): valobj = self.expect_var_path( "up_int_ref_ref", - type="std::unique_ptr &&", + type="std::unique_ptr > &&", summary="10", children=[ValueCheck(name="__value_")], ) @@ -60,13 +60,13 @@ class TestCase(TestBase): valobj = self.expect_var_path( "up_str", - type="std::unique_ptr >", + type="std::unique_ptr, std::allocator >, std::default_delete, std::allocator > > >", summary='"hello"', children=[ValueCheck(name="__value_", summary='"hello"')], ) valobj = self.expect_var_path( - "up_user", type="std::unique_ptr" + "up_user", type="std::unique_ptr >" ) self.assertRegex(valobj.summary, "^User @ 0x0*[1-9a-f][0-9a-f]+$") self.assertNotEqual(valobj.child[0].unsigned, 0) diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt index 4a37ece..6af8661 100644 --- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt +++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt @@ -24,7 +24,6 @@ add_lldb_unittest(SymbolFileDWARFTests ) set(test_inputs - test-dwarf.exe - DW_AT_default_value-test.yaml) + test-dwarf.exe) add_unittest_inputs(SymbolFileDWARFTests "${test_inputs}") diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index ecdb159..4d1c2ae 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -11,7 +11,6 @@ #include "Plugins/SymbolFile/DWARF/DWARFDIE.h" #include "TestingSupport/Symbol/ClangTestUtils.h" #include "TestingSupport/Symbol/YAMLModuleTester.h" -#include "lldb/Core/Debugger.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -20,16 +19,7 @@ using namespace lldb_private; using namespace lldb_private::dwarf; namespace { -static std::once_flag debugger_initialize_flag; - -class DWARFASTParserClangTests : public testing::Test { - void SetUp() override { - HostInfo::Initialize(); - std::call_once(debugger_initialize_flag, - []() { Debugger::Initialize(nullptr); }); - } - void TearDown() override { HostInfo::Terminate(); } -}; +class DWARFASTParserClangTests : public testing::Test {}; class DWARFASTParserClangStub : public DWARFASTParserClang { public: @@ -414,53 +404,3 @@ TEST_F(ExtractIntFromFormValueTest, TestUnsignedInt) { EXPECT_THAT_EXPECTED(Extract(ast.UnsignedIntTy, uint_max + 2), llvm::Failed()); } - -TEST_F(DWARFASTParserClangTests, TestDefaultTemplateParamParsing) { - // Tests parsing DW_AT_default_value for template parameters. - auto BufferOrError = llvm::MemoryBuffer::getFile( - GetInputFilePath("DW_AT_default_value-test.yaml"), /*IsText=*/true); - ASSERT_TRUE(BufferOrError); - YAMLModuleTester t(BufferOrError.get()->getBuffer()); - - DWARFUnit *unit = t.GetDwarfUnit(); - ASSERT_NE(unit, nullptr); - const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE(); - ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit); - DWARFDIE cu_die(unit, cu_entry); - - auto holder = std::make_unique("ast"); - auto &ast_ctx = *holder->GetAST(); - DWARFASTParserClangStub ast_parser(ast_ctx); - - llvm::SmallVector types; - for (DWARFDIE die : cu_die.children()) { - if (die.Tag() == DW_TAG_class_type) { - SymbolContext sc; - bool new_type = false; - types.push_back(ast_parser.ParseTypeFromDWARF(sc, die, &new_type)); - } - } - - ASSERT_EQ(types.size(), 3U); - - auto check_decl = [](auto const *decl) { - clang::ClassTemplateSpecializationDecl const *ctsd = - llvm::dyn_cast_or_null(decl); - ASSERT_NE(ctsd, nullptr); - - auto const &args = ctsd->getTemplateArgs(); - ASSERT_GT(args.size(), 0U); - - for (auto const &arg : args.asArray()) { - EXPECT_TRUE(arg.getIsDefaulted()); - } - }; - - for (auto const &type_sp : types) { - ASSERT_NE(type_sp, nullptr); - auto const *decl = ClangUtil::GetAsTagDecl(type_sp->GetFullCompilerType()); - if (decl->getName() == "bar" || decl->getName() == "baz") { - check_decl(decl); - } - } -} diff --git a/lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml b/lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml deleted file mode 100644 index 2e83d37..0000000 --- a/lldb/unittests/SymbolFile/DWARF/Inputs/DW_AT_default_value-test.yaml +++ /dev/null @@ -1,314 +0,0 @@ -# template -# class foo {}; -# -# template