@@ -24,18 +24,16 @@ using namespace llvm::logicalview;
2424void LVSymbolTable::add (StringRef Name, LVScope *Function,
2525 LVSectionIndex SectionIndex) {
2626 std::string SymbolName (Name);
27- if (SymbolNames.find (SymbolName) == SymbolNames.end ()) {
28- SymbolNames.emplace (
29- std::piecewise_construct, std::forward_as_tuple (SymbolName),
30- std::forward_as_tuple (Function, 0 , SectionIndex, false ));
31- } else {
27+ auto [It, Inserted] =
28+ SymbolNames.try_emplace (SymbolName, Function, 0 , SectionIndex, false );
29+ if (!Inserted) {
3230 // Update a recorded entry with its logical scope and section index.
33- SymbolNames[SymbolName] .Scope = Function;
31+ It-> second .Scope = Function;
3432 if (SectionIndex)
35- SymbolNames[SymbolName] .SectionIndex = SectionIndex;
33+ It-> second .SectionIndex = SectionIndex;
3634 }
3735
38- if (Function && SymbolNames[SymbolName] .IsComdat )
36+ if (Function && It-> second .IsComdat )
3937 Function->setIsComdat ();
4038
4139 LLVM_DEBUG ({ print (dbgs ()); });
@@ -44,15 +42,13 @@ void LVSymbolTable::add(StringRef Name, LVScope *Function,
4442void LVSymbolTable::add (StringRef Name, LVAddress Address,
4543 LVSectionIndex SectionIndex, bool IsComdat) {
4644 std::string SymbolName (Name);
47- if (SymbolNames.find (SymbolName) == SymbolNames.end ())
48- SymbolNames.emplace (
49- std::piecewise_construct, std::forward_as_tuple (SymbolName),
50- std::forward_as_tuple (nullptr , Address, SectionIndex, IsComdat));
51- else
45+ auto [It, Inserted] = SymbolNames.try_emplace (SymbolName, nullptr , Address,
46+ SectionIndex, IsComdat);
47+ if (!Inserted)
5248 // Update a recorded symbol name with its logical scope.
53- SymbolNames[SymbolName] .Address = Address;
49+ It-> second .Address = Address;
5450
55- LVScope *Function = SymbolNames[SymbolName] .Scope ;
51+ LVScope *Function = It-> second .Scope ;
5652 if (Function && IsComdat)
5753 Function->setIsComdat ();
5854 LLVM_DEBUG ({ print (dbgs ()); });
0 commit comments