Verifier: Check that !dbg attachments have the right type
[oota-llvm.git] / lib / IR / Verifier.cpp
index ce765b14420f5794a4e101370b1e193fa89a24db..4f0e3388d58a39154dfe2b05a4fe934f945d45c8 100644 (file)
@@ -2556,6 +2556,13 @@ void Verifier::visitInstruction(Instruction &I) {
            &I);
   }
 
+  // Don't recurse into !dbg attachments (leave that for verifyDebugInfo()),
+  // but at least check that it's a legal type.
+  if (MDNode *N = I.getDebugLoc().getAsMDNode()) {
+    Assert(isa<MDLocation>(N),
+           "invalid !dbg metadata attachment", &I, N);
+  }
+
   InstsInThisBlock.insert(&I);
 }