Add an assert and use a range loop. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 28 Nov 2014 16:26:14 +0000 (16:26 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 28 Nov 2014 16:26:14 +0000 (16:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222922 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp

index f1f4a51f78c7a23c6424ab82b60f8f4b12f573de..d3cb78c6997517e34cee0348d6ee32ff62640de8 100644 (file)
@@ -94,13 +94,15 @@ private:
 }
 
 void TypeMapTy::addTypeMapping(Type *DstTy, Type *SrcTy) {
+  assert(SpeculativeTypes.empty());
+
   // Check to see if these types are recursively isomorphic and establish a
   // mapping between them if so.
   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]);
+    for (Type *Ty : SpeculativeTypes)
+      MappedTypes.erase(Ty);
   }
   SpeculativeTypes.clear();
 }