Fix if/else brackets; getFunctionForValue() is to be called for non-metadata values
authorVictor Hernandez <vhernandez@apple.com>
Wed, 20 Jan 2010 06:22:33 +0000 (06:22 +0000)
committerVictor Hernandez <vhernandez@apple.com>
Wed, 20 Jan 2010 06:22:33 +0000 (06:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93984 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Metadata.cpp

index b4a981f3a02677339a3479ec786527d16f7d52bd..acc3b8ee5ef0f97f07f4b52e566de0f0b3aef00e 100644 (file)
@@ -122,6 +122,7 @@ MDNode::~MDNode() {
 }
 
 static const Function *getFunctionForValue(Value *V) {
+  assert(!isa<MDNode>(V) && "does not iterate over metadata operands");
   if (!V) return NULL;
   if (Instruction *I = dyn_cast<Instruction>(V))
     return I->getParent()->getParent();
@@ -161,7 +162,8 @@ const Function *MDNode::getFunction() const {
     if (Value *V = getOperand(i)) {
       if (MDNode *MD = dyn_cast<MDNode>(V)) {
         if (const Function *F = MD->getFunction()) return F;
-        else return getFunctionForValue(V);
+      } else {
+        return getFunctionForValue(V);
       }
     }
   }