forked from OSchip/llvm-project
[ORC] Avoid invalidating iterators in EHFrameRegistrationPlugin.
In EHFrameRegistrationPlugin::notifyTransferringResources if SrcKey had eh-frames associated but DstKey did not we would create a new entry for DskKey, invalidating the iterator for SrcKey in the process. This commit fixes that by removing SrcKey first in this case.
This commit is contained in:
parent
c624e70149
commit
c1baf946e6
|
@ -654,13 +654,23 @@ Error EHFrameRegistrationPlugin::notifyRemovingResources(ResourceKey K) {
|
|||
void EHFrameRegistrationPlugin::notifyTransferringResources(
|
||||
ResourceKey DstKey, ResourceKey SrcKey) {
|
||||
auto SI = EHFrameRanges.find(SrcKey);
|
||||
if (SI != EHFrameRanges.end()) {
|
||||
if (SI == EHFrameRanges.end())
|
||||
return;
|
||||
|
||||
auto DI = EHFrameRanges.find(DstKey);
|
||||
if (DI != EHFrameRanges.end()) {
|
||||
auto &SrcRanges = SI->second;
|
||||
auto &DstRanges = EHFrameRanges[DstKey];
|
||||
auto &DstRanges = DI->second;
|
||||
DstRanges.reserve(DstRanges.size() + SrcRanges.size());
|
||||
for (auto &SrcRange : SrcRanges)
|
||||
DstRanges.push_back(std::move(SrcRange));
|
||||
EHFrameRanges.erase(SI);
|
||||
} else {
|
||||
// We need to move SrcKey's ranges over without invalidating the SI
|
||||
// iterator.
|
||||
auto Tmp = std::move(SI->second);
|
||||
EHFrameRanges.erase(SI);
|
||||
EHFrameRanges[DstKey] = std::move(Tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue