Verifier: Check that all instructions have their parent pointers set up
authorAdrian Prantl <aprantl@apple.com>
Fri, 21 Nov 2014 00:39:43 +0000 (00:39 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 21 Nov 2014 00:39:43 +0000 (00:39 +0000)
correctly. This helps with catching problems caused by IRBuilder abuse
such as the one fixed in CFE r222487.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222488 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Verifier.cpp

index d42ca31b5aa7795043ee0175ce49248ba4a65e2b..05600155a8c390aaebb528de305d77e063b07701 100644 (file)
@@ -1176,6 +1176,10 @@ void Verifier::visitBasicBlock(BasicBlock &BB) {
       }
     }
   }
+
+  // Check that all instructions have their parent pointers set up correctly.
+  for (auto &I: BB)
+    Assert(I.getParent() == &BB, "Instruction has bogus parent pointer!");
 }
 
 void Verifier::visitTerminatorInst(TerminatorInst &I) {