[llvm] [DebugInfo] Simplify code with std::unordered_map::operator[] (NFC) (PR #112658)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 20:36:42 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/112658

None

>From a50ab99fc8145a27d9616b8bb13aeebb11d83dce Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 16 Oct 2024 06:57:01 -0700
Subject: [PATCH] [DebugInfo] Simplify code with std::unordered_map::operator[]
 (NFC)

---
 llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
index e85356b5eab0f4..1c523c01314977 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
@@ -1139,9 +1139,8 @@ void LVDWARFReader::updateReference(dwarf::Attribute Attr,
 // Get an element given the DIE offset.
 LVElement *LVDWARFReader::getElementForOffset(LVOffset Offset,
                                               LVElement *Element, bool IsType) {
-  auto Iter = ElementTable.try_emplace(Offset).first;
   // Update the element and all the references pointing to this element.
-  LVElementEntry &Entry = Iter->second;
+  LVElementEntry &Entry = ElementTable[Offset];
   if (!Entry.Element) {
     if (IsType)
       Entry.Types.insert(Element);



More information about the llvm-commits mailing list