Skip to content

Commit 593820d

Browse files
lhamesvchuravy
authored andcommitted
[JITLink] Fix element-present check in MachOLinkGraphParser.
Not all symbols are added to the index-to-symbol map, so we shouldn't use the size of the map as a proxy for the highest valid index. (cherry-picked from 91434d4)
1 parent 42d932f commit 593820d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,12 @@ class MachOLinkGraphBuilder {
125125
/// given index is out of range, or if no symbol has been added for the given
126126
/// index.
127127
Expected<NormalizedSymbol &> findSymbolByIndex(uint64_t Index) {
128-
if (Index >= IndexToSymbol.size())
129-
return make_error<JITLinkError>("Symbol index out of range");
130-
auto *Sym = IndexToSymbol[Index];
131-
if (!Sym)
128+
auto I = IndexToSymbol.find(Index);
129+
if (I == IndexToSymbol.end())
132130
return make_error<JITLinkError>("No symbol at index " +
133131
formatv("{0:d}", Index));
134-
return *Sym;
132+
assert(I->second && "Null symbol at index");
133+
return *I->second;
135134
}
136135

137136
/// Returns the symbol with the highest address not greater than the search

0 commit comments

Comments
 (0)