From c8ef21f1b1e1297c2473be6444f5196dd0b7cd29 Mon Sep 17 00:00:00 2001
From: Adrian Prantl <aprantl@apple.com>
Date: Fri, 21 Nov 2014 00:39:43 +0000
Subject: [PATCH] Verifier: Check that all instructions have their parent
 pointers set up 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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index d42ca31b5aa..05600155a8c 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -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) {