[PATCH] D116106: [unittest][DebugInfo/DWARF] Check that dwarfgen::Generator is created
Igor Kudrin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 22 03:54:27 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5fc05a0a81ed: [unittest][DebugInfo/DWARF] Check that dwarfgen::Generator is created (authored by ikudrin).
Changed prior to commit:
https://reviews.llvm.org/D116106?vs=395666&id=395838#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116106/new/
https://reviews.llvm.org/D116106
Files:
llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -36,16 +36,21 @@
EXPECT_FALSE(Unrecoverable);
}
- bool setupGenerator(uint16_t Version = 4, uint8_t AddrSize = 8) {
+ // Note: ASSERT_THAT_EXPECTED cannot be used in a non-void function, so
+ // setupGenerator() is split into two.
+ void setupGeneratorImpl(uint16_t Version, uint8_t AddrSize) {
AddressSize = AddrSize;
- Triple T =
- getDefaultTargetTripleForAddrSize(AddressSize == 0 ? 8 : AddressSize);
+ Triple T = getDefaultTargetTripleForAddrSize(AddressSize ? AddressSize : 8);
if (!isConfigurationSupported(T))
- return false;
+ return;
auto ExpectedGenerator = Generator::create(T, Version);
- if (ExpectedGenerator)
- Gen.reset(ExpectedGenerator->release());
- return true;
+ ASSERT_THAT_EXPECTED(ExpectedGenerator, Succeeded());
+ Gen = std::move(*ExpectedGenerator);
+ }
+
+ bool setupGenerator(uint16_t Version = 4, uint8_t AddrSize = 8) {
+ setupGeneratorImpl(Version, AddrSize);
+ return Gen != nullptr;
}
void generate() {
@@ -60,8 +65,7 @@
}
std::unique_ptr<DWARFContext> createContext() {
- if (!Gen)
- return nullptr;
+ assert(Gen != nullptr && "Generator is not set up");
StringRef FileBytes = Gen->generate();
MemoryBufferRef FileBuffer(FileBytes, "dwarf");
auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116106.395838.patch
Type: text/x-patch
Size: 1606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211222/5a24deec/attachment.bin>
More information about the llvm-commits
mailing list