[Lldb-commits] [lldb] 43db8ac - [lldb] Fix missing comsumeError() with LLDB_LOG in ObjectFileCOFF/PECOFF (#70793)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 1 04:09:16 PDT 2023
Author: Stefan Gränitz
Date: 2023-11-01T12:09:12+01:00
New Revision: 43db8ac8ae56f24b5c06e9edb194fe1b7e9cbda0
URL: https://github.com/llvm/llvm-project/commit/43db8ac8ae56f24b5c06e9edb194fe1b7e9cbda0
DIFF: https://github.com/llvm/llvm-project/commit/43db8ac8ae56f24b5c06e9edb194fe1b7e9cbda0.diff
LOG: [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.
Added:
Modified:
lldb/source/Plugins/ObjectFile/COFF/ObjectFileCOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ObjectFile/COFF/ObjectFileCOFF.cpp b/lldb/source/Plugins/ObjectFile/COFF/ObjectFileCOFF.cpp
index 03c454bf3efab14..a7ad5d27b237f12 100644
--- a/lldb/source/Plugins/ObjectFile/COFF/ObjectFileCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/COFF/ObjectFileCOFF.cpp
@@ -271,9 +271,9 @@ void ObjectFileCOFF::ParseSymtab(lldb_private::Symtab &symtab) {
const auto COFFSymRef = m_object->getCOFFSymbol(SymRef);
Expected<StringRef> NameOrErr = SymRef.getName();
- if (auto error = NameOrErr.takeError()) {
- LLDB_LOG(log, "ObjectFileCOFF: failed to get symbol name: {0}",
- llvm::fmt_consume(std::move(error)));
+ if (!NameOrErr) {
+ LLDB_LOG_ERROR(log, NameOrErr.takeError(),
+ "ObjectFileCOFF: failed to get symbol name: {0}");
continue;
}
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 7fb10a69391c566..be0020cad5bee8e 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -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;
More information about the lldb-commits
mailing list