[llvm-commits] [llvm] r94100 - /llvm/trunk/lib/VMCore/Metadata.cpp

Chris Lattner sabre at nondot.org
Thu Jan 21 13:01:48 PST 2010


Author: lattner
Date: Thu Jan 21 15:01:47 2010
New Revision: 94100

URL: http://llvm.org/viewvc/llvm-project?rev=94100&view=rev
Log:
tidy up

Modified:
    llvm/trunk/lib/VMCore/Metadata.cpp

Modified: llvm/trunk/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=94100&r1=94099&r2=94100&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp (original)
+++ llvm/trunk/lib/VMCore/Metadata.cpp Thu Jan 21 15:01:47 2010
@@ -126,23 +126,29 @@
   if (!V) return NULL;
   if (Instruction *I = dyn_cast<Instruction>(V))
     return I->getParent()->getParent();
-  if (BasicBlock *BB = dyn_cast<BasicBlock>(V)) return BB->getParent();
-  if (Argument *A = dyn_cast<Argument>(V)) return A->getParent();
+  if (BasicBlock *BB = dyn_cast<BasicBlock>(V))
+    return BB->getParent();
+  if (Argument *A = dyn_cast<Argument>(V))
+    return A->getParent();
   return NULL;
 }
 
 #ifndef NDEBUG
 static const Function *assertLocalFunction(const MDNode *N) {
-  if (!N->isFunctionLocal()) return NULL;
+  if (!N->isFunctionLocal()) return 0;
 
-  const Function *F = NULL, *NewF = NULL;
+  const Function *F = 0, *NewF = 0;
   for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
     if (Value *V = N->getOperand(i)) {
-      if (MDNode *MD = dyn_cast<MDNode>(V)) NewF = assertLocalFunction(MD);
-      else NewF = getFunctionForValue(V);
+      if (MDNode *MD = dyn_cast<MDNode>(V))
+        NewF = assertLocalFunction(MD);
+      else
+        NewF = getFunctionForValue(V);
     }
-    if (F && NewF) assert(F == NewF && "inconsistent function-local metadata");
-    else if (!F) F = NewF;
+    if (F == 0)
+      F = NewF;
+    else 
+      assert((NewF == 0 || F == NewF) &&"inconsistent function-local metadata");
   }
   return F;
 }
@@ -161,7 +167,8 @@
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     if (Value *V = getOperand(i)) {
       if (MDNode *MD = dyn_cast<MDNode>(V)) {
-        if (const Function *F = MD->getFunction()) return F;
+        if (const Function *F = MD->getFunction())
+          return F;
       } else {
         return getFunctionForValue(V);
       }





More information about the llvm-commits mailing list