[llvm] 557448e - [DebugInfo] Use std::map::try_emplace (NFC) (#140839)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 20 21:39:38 PDT 2025
Author: Kazu Hirata
Date: 2025-05-20T21:39:34-07:00
New Revision: 557448e14420e1a916280ea6c61cafbf833ff948
URL: https://github.com/llvm/llvm-project/commit/557448e14420e1a916280ea6c61cafbf833ff948
DIFF: https://github.com/llvm/llvm-project/commit/557448e14420e1a916280ea6c61cafbf833ff948.diff
LOG: [DebugInfo] Use std::map::try_emplace (NFC) (#140839)
This patch provides default member initialization for SymInfo, which
in turns allows us to call std::map::try_emplace without the value.
Added:
Modified:
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 27aa99ae94fce..6d0a94d8a3367 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1902,8 +1902,8 @@ static Error createError(const Twine &Reason, llvm::Error E) {
/// SymInfo contains information about symbol: it's address
/// and section index which is -1LL for absolute symbols.
struct SymInfo {
- uint64_t Address;
- uint64_t SectionIndex;
+ uint64_t Address = 0;
+ uint64_t SectionIndex = 0;
};
/// Returns the address of symbol relocation used against and a section index.
@@ -1921,7 +1921,7 @@ static Expected<SymInfo> getSymbolInfo(const object::ObjectFile &Obj,
// in the object file
if (Sym != Obj.symbol_end()) {
bool New;
- std::tie(CacheIt, New) = Cache.insert({*Sym, {0, 0}});
+ std::tie(CacheIt, New) = Cache.try_emplace(*Sym);
if (!New)
return CacheIt->second;
More information about the llvm-commits
mailing list