Fix Value dangling reference debug output
authorAndrew Kaylor <andrew.kaylor@intel.com>
Tue, 10 Mar 2015 23:55:38 +0000 (23:55 +0000)
committerAndrew Kaylor <andrew.kaylor@intel.com>
Tue, 10 Mar 2015 23:55:38 +0000 (23:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231889 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/TypeFinder.cpp
lib/IR/Value.cpp

index e2fb8f84b186f1f86d25171ae3077e01adb0935d..1d2b808d650e1905a2a1ff8be5bb28028d13cd20 100644 (file)
@@ -68,7 +68,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
         // instructions with this loop.)
         for (User::const_op_iterator OI = I.op_begin(), OE = I.op_end();
              OI != OE; ++OI)
-          if (!isa<Instruction>(OI))
+          if (*OI && !isa<Instruction>(OI))
             incorporateValue(*OI);
 
         // Incorporate types hiding in metadata.
index 00ec81fea80eb1d52aff370a00259f7bd892663b..2d9c306d72381ee61301ac0396102ba68f7716a4 100644 (file)
@@ -69,15 +69,13 @@ Value::~Value() {
 #ifndef NDEBUG      // Only in -g mode...
   // Check to make sure that there are no uses of this value that are still
   // around when the value is destroyed.  If there are, then we have a dangling
-  // reference and something is wrong.  This code is here to print out what is
-  // still being referenced.  The value in question should be printed as
-  // a <badref>
+  // reference and something is wrong.  This code is here to print out where
+  // the value is still being referenced.
   //
   if (!use_empty()) {
     dbgs() << "While deleting: " << *VTy << " %" << getName() << "\n";
-    for (use_iterator I = use_begin(), E = use_end(); I != E; ++I)
-      dbgs() << "Use still stuck around after Def is destroyed:"
-           << **I << "\n";
+    for (auto *U : users())
+      dbgs() << "Use still stuck around after Def is destroyed:" << *U << "\n";
   }
 #endif
   assert(use_empty() && "Uses remain when a value is destroyed!");