diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h index 90b14c44ff8a8d..33fa84821ceba3 100644 --- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h +++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h @@ -125,13 +125,12 @@ class MachOLinkGraphBuilder { /// given index is out of range, or if no symbol has been added for the given /// index. Expected findSymbolByIndex(uint64_t Index) { - if (Index >= IndexToSymbol.size()) - return make_error("Symbol index out of range"); - auto *Sym = IndexToSymbol[Index]; - if (!Sym) + auto I = IndexToSymbol.find(Index); + if (I == IndexToSymbol.end()) return make_error("No symbol at index " + formatv("{0:d}", Index)); - return *Sym; + assert(I->second && "Null symbol at index"); + return *I->second; } /// Returns the symbol with the highest address not greater than the search