Skip to content

Commit 557448e

Browse files
[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.
1 parent 51b288d commit 557448e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,8 +1902,8 @@ static Error createError(const Twine &Reason, llvm::Error E) {
19021902
/// SymInfo contains information about symbol: it's address
19031903
/// and section index which is -1LL for absolute symbols.
19041904
struct SymInfo {
1905-
uint64_t Address;
1906-
uint64_t SectionIndex;
1905+
uint64_t Address = 0;
1906+
uint64_t SectionIndex = 0;
19071907
};
19081908

19091909
/// Returns the address of symbol relocation used against and a section index.
@@ -1921,7 +1921,7 @@ static Expected<SymInfo> getSymbolInfo(const object::ObjectFile &Obj,
19211921
// in the object file
19221922
if (Sym != Obj.symbol_end()) {
19231923
bool New;
1924-
std::tie(CacheIt, New) = Cache.insert({*Sym, {0, 0}});
1924+
std::tie(CacheIt, New) = Cache.try_emplace(*Sym);
19251925
if (!New)
19261926
return CacheIt->second;
19271927

0 commit comments

Comments
 (0)