diff --git a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp index 6549ec9f0f547..15db62451f91a 100644 --- a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp +++ b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp @@ -9,7 +9,6 @@ #include "TestingSupport/Symbol/YAMLModuleTester.h" #include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" -#include "TestingSupport/TestUtilities.h" #include "lldb/Core/Section.h" #include "llvm/ObjectYAML/DWARFEmitter.h" @@ -18,8 +17,9 @@ using namespace lldb_private; YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data) { llvm::Expected File = TestFile::fromYaml(yaml_data); EXPECT_THAT_EXPECTED(File, llvm::Succeeded()); + m_file = std::move(*File); - m_module_sp = std::make_shared(File->moduleSpec()); + m_module_sp = std::make_shared(m_file->moduleSpec()); auto &symfile = *llvm::cast(m_module_sp->GetSymbolFile()); m_dwarf_unit = symfile.DebugInfo().GetUnitAtIndex(0); diff --git a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h index 69bb392aaaf6f..60715ab2c16a6 100644 --- a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h +++ b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h @@ -14,6 +14,7 @@ #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "TestingSupport/SubsystemRAII.h" +#include "TestingSupport/TestUtilities.h" #include "lldb/Core/Module.h" #include "lldb/Host/HostInfo.h" @@ -26,6 +27,7 @@ class YAMLModuleTester { SubsystemRAII subsystems; + llvm::Optional m_file; lldb::ModuleSP m_module_sp; DWARFUnit *m_dwarf_unit; diff --git a/lldb/unittests/TestingSupport/TestUtilities.h b/lldb/unittests/TestingSupport/TestUtilities.h index 60a07119e9243..811c4c1521269 100644 --- a/lldb/unittests/TestingSupport/TestUtilities.h +++ b/lldb/unittests/TestingSupport/TestUtilities.h @@ -36,8 +36,6 @@ class TestFile { static llvm::Expected fromYaml(llvm::StringRef Yaml); static llvm::Expected fromYamlFile(const llvm::Twine &Name); - ~TestFile() = default; - ModuleSpec moduleSpec() { return ModuleSpec(FileSpec(), UUID(), dataBuffer()); } @@ -45,8 +43,6 @@ class TestFile { private: TestFile(std::string &&Buffer) : Buffer(std::move(Buffer)) {} - void operator=(const TestFile &) = delete; - lldb::DataBufferSP dataBuffer() { auto *Data = reinterpret_cast(Buffer.data()); return std::make_shared(const_cast(Data),