[lldb] Fix missing comsumeError() with LLDB_LOG in ObjectFileCOFF/PECOFF (#70793)

All `llvm::Error`s must be checked/consumed before destruction. Previously,
the errors in this patch were only consumed when logging was enabled.
Using `LLDB_LOG_ERROR` instead of `LLDB_LOG` fixes that, because it
calls `llvm::consumeError()` explicitly when logging is disabled.
This commit is contained in:
Stefan Gränitz
2023-11-01 12:09:12 +01:00
committed by GitHub
parent 4a7702b785
commit 43db8ac8ae
2 changed files with 7 additions and 8 deletions

View File

@@ -791,11 +791,10 @@ void ObjectFilePECOFF::AppendFromCOFFSymbolTable(
for (const auto &sym_ref : m_binary->symbols()) {
const auto coff_sym_ref = m_binary->getCOFFSymbol(sym_ref);
auto name_or_error = sym_ref.getName();
if (auto err = name_or_error.takeError()) {
LLDB_LOG(log,
"ObjectFilePECOFF::AppendFromCOFFSymbolTable - failed to get "
"symbol table entry name: {0}",
llvm::fmt_consume(std::move(err)));
if (!name_or_error) {
LLDB_LOG_ERROR(log, name_or_error.takeError(),
"ObjectFilePECOFF::AppendFromCOFFSymbolTable - failed to "
"get symbol table entry name: {0}");
continue;
}
const llvm::StringRef sym_name = *name_or_error;