[llvm] r229361 - Verifier: Diagnose module flags which have null ID operands
David Majnemer
david.majnemer at gmail.com
Mon Feb 16 00:14:22 PST 2015
Author: majnemer
Date: Mon Feb 16 02:14:22 2015
New Revision: 229361
URL: http://llvm.org/viewvc/llvm-project?rev=229361&view=rev
Log:
Verifier: Diagnose module flags which have null ID operands
Added:
llvm/trunk/test/Verifier/module-flags-3.ll
Modified:
llvm/trunk/lib/IR/Verifier.cpp
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=229361&r1=229360&r2=229361&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Mon Feb 16 02:14:22 2015
@@ -877,7 +877,7 @@ Verifier::visitModuleFlag(const MDNode *
"invalid behavior operand in module flag (unexpected constant)",
Op->getOperand(0));
}
- MDString *ID = dyn_cast<MDString>(Op->getOperand(1));
+ MDString *ID = dyn_cast_or_null<MDString>(Op->getOperand(1));
Assert1(ID,
"invalid ID operand in module flag (expected metadata string)",
Op->getOperand(1));
Added: llvm/trunk/test/Verifier/module-flags-3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/module-flags-3.ll?rev=229361&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/module-flags-3.ll (added)
+++ llvm/trunk/test/Verifier/module-flags-3.ll Mon Feb 16 02:14:22 2015
@@ -0,0 +1,6 @@
+; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, null, null}
+
+; CHECK: invalid ID operand in module flag (expected metadata string)
More information about the llvm-commits
mailing list