IR: Instruction::setMetadata() should use cast_or_null
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 31 Oct 2014 20:28:04 +0000 (20:28 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 31 Oct 2014 20:28:04 +0000 (20:28 +0000)
Not sure why this assertion didn't fire locally [1], but in r220994
`Instruction::setMetadata()` should be using `cast_or_null`.

[1]: http://lab.llvm.org:8011/builders/llvm-hexagon-elf/builds/12327

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

lib/IR/Metadata.cpp

index 24c78fea64617d7fd39c6ad28e1f8c8cc0e05efa..3d869e87c4d34d60adf7bfaa22b596c2074ad48e 100644 (file)
@@ -660,7 +660,7 @@ void Instruction::setMetadata(unsigned KindID, Value *MD) {
   if (!MD && !hasMetadata()) return;
 
   // For now, we only expect MDNodes here.
-  MDNode *Node = cast<MDNode>(MD);
+  MDNode *Node = cast_or_null<MDNode>(MD);
 
   // Handle 'dbg' as a special case since it is not stored in the hash table.
   if (KindID == LLVMContext::MD_dbg) {