diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h index 4c82768f9fdbff..d6ea4e2c244cf0 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