Add missing newlines at EOF (for clang++).
[oota-llvm.git] / lib / VMCore / Verifier.cpp
index 7ab7b1516844d95091a2a0494fcee69ceb0c6c79..a1b89dedeabb9bccb70da585339422b76c84953c 100644 (file)
@@ -1475,6 +1475,9 @@ void Verifier::visitInstruction(Instruction &I) {
 void Verifier::VerifyType(const Type *Ty) {
   if (!Types.insert(Ty)) return;
 
+  Assert1(&Mod->getContext() == &Ty->getContext(),
+          "Type context does not match Module context!", Ty);
+
   switch (Ty->getTypeID()) {
   case Type::FunctionTyID: {
     const FunctionType *FTy = cast<FunctionType>(Ty);
@@ -1539,6 +1542,16 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
 #include "llvm/Intrinsics.gen"
 #undef GET_INTRINSIC_VERIFIER
 
+  for (unsigned i = 0, e = CI.getNumOperands(); i != e; ++i)
+    if (MDNode *MD = dyn_cast<MDNode>(CI.getOperand(i))) {
+      Function* LocalFunction = NULL;
+      Assert1(MD && MD->getLocalFunction(LocalFunction),
+              "invalid function-local metadata", &CI);
+      if (LocalFunction)
+        Assert1(LocalFunction == CI.getParent()->getParent(),
+                "function-local metadata used in wrong function", &CI);
+    }
+
   switch (ID) {
   default:
     break;