- if (!areTypesIsomorphic(DstTy, SrcTy)) {
- // Oops, they aren't isomorphic. Just discard this request by rolling out
- // any speculative mappings we've established.
- for (unsigned i = 0, e = SpeculativeTypes.size(); i != e; ++i)
- MappedTypes.erase(SpeculativeTypes[i]);
+ if (areTypesIsomorphic(DstTy, SrcTy)) {
+ SpeculativeTypes.clear();
+ return;
+ }
+
+ // Oops, they aren't isomorphic. Just discard this request by rolling out
+ // any speculative mappings we've established.
+ unsigned Removed = 0;
+ for (unsigned I = 0, E = SpeculativeTypes.size(); I != E; ++I) {
+ Type *SrcTy = SpeculativeTypes[I];
+ auto Iter = MappedTypes.find(SrcTy);
+ auto *DstTy = dyn_cast<StructType>(Iter->second);
+ if (DstTy && DstResolvedOpaqueTypes.erase(DstTy))
+ Removed++;
+ MappedTypes.erase(Iter);