aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin@accesssoftek.com>2021-12-22 18:52:36 +0700
committerIgor Kudrin <ikudrin@accesssoftek.com>2021-12-22 18:52:36 +0700
commit5fc05a0a81ed06e936196b68ba99ffddcbffd14d (patch)
tree583d7d0e21276db6d21d7a80a8b1cb76585381f3 /llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
parent6e9be9f7c124a181118e293e8f57ce7559d9478e (diff)
downloadllvm-5fc05a0a81ed06e936196b68ba99ffddcbffd14d.zip
llvm-5fc05a0a81ed06e936196b68ba99ffddcbffd14d.tar.gz
llvm-5fc05a0a81ed06e936196b68ba99ffddcbffd14d.tar.bz2
[unittest][DebugInfo/DWARF] Check that dwarfgen::Generator is created
If Generator::create() returns an error, tests should fail gracefully and report the cause, for example: [ RUN ] DebugLineBasicFixture.ParserSkipsCorrectly .../llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp:47: Failure Value of: llvm::detail::TakeExpected(ExpectedGenerator) Expected: succeeded Actual: failed (no asm backend for target nvptx64-nvidia-cuda) Differential Revision: https://reviews.llvm.org/D116106
Diffstat (limited to 'llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp')
-rw-r--r--llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
index a8502df..71b7361 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp
@@ -36,16 +36,21 @@ struct CommonFixture {
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 @@ struct CommonFixture {
}
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);