From 5751a217316871ae7ff26461616a949336959939 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 12 Sep 2024 22:40:55 -0700 Subject: [PATCH] [DebugInfo] Use std::map::try_emplace (NFC) This patch provides default member initialization for SymInfo, which in turns allows us to call std::map::try_emplace without the value. --- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 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;