Use assertion instead of early exit to catch malformed custom metadata store.
authorDevang Patel <dpatel@apple.com>
Tue, 29 Sep 2009 20:01:19 +0000 (20:01 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 29 Sep 2009 20:01:19 +0000 (20:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83102 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Metadata.cpp

index 8ae7d309b31c6d357e762c85eac0f21f7ee9b108..0a8e865cff6f5918c6c6485c6e5b4dcf3f6b1180 100644 (file)
@@ -351,15 +351,14 @@ const StringMap<unsigned> *MetadataContext::getHandlerNames() {
 void MetadataContext::ValueIsDeleted(const Instruction *Inst) {
   // Find Metadata handles for this instruction.
   MDStoreTy::iterator I = MetadataStore.find(Inst);
-  if (I == MetadataStore.end())
-    return;
+  assert (I != MetadataStore.end() && "Invalid custom metadata info!");
   MDMapTy &Info = I->second;
   
   // FIXME : Give all metadata handlers a chance to adjust.
   
   // Remove the entries for this instruction.
   Info.clear();
-  MetadataStore.erase(Inst);
+  MetadataStore.erase(I);
 }
 
 /// ValueIsCloned - This handler is used to update metadata store
@@ -367,8 +366,7 @@ void MetadataContext::ValueIsDeleted(const Instruction *Inst) {
 void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) {
   // Find Metadata handles for In1.
   MDStoreTy::iterator I = MetadataStore.find(In1);
-  if (I == MetadataStore.end())
-    return;
+  assert (I != MetadataStore.end() && "Invalid custom metadata info!");
 
   // FIXME : Give all metadata handlers a chance to adjust.