From 815c05d38c928cf2080fe542e6d96743567e7eaf Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 16 Feb 2015 08:14:22 +0000 Subject: [PATCH] Verifier: Diagnose module flags which have null ID operands git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229361 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Verifier.cpp | 2 +- test/Verifier/module-flags-3.ll | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/Verifier/module-flags-3.ll diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 22a5a9620b0..0b9f6786000 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -877,7 +877,7 @@ Verifier::visitModuleFlag(const MDNode *Op, "invalid behavior operand in module flag (unexpected constant)", Op->getOperand(0)); } - MDString *ID = dyn_cast(Op->getOperand(1)); + MDString *ID = dyn_cast_or_null(Op->getOperand(1)); Assert1(ID, "invalid ID operand in module flag (expected metadata string)", Op->getOperand(1)); diff --git a/test/Verifier/module-flags-3.ll b/test/Verifier/module-flags-3.ll new file mode 100644 index 00000000000..64ab57ed786 --- /dev/null +++ b/test/Verifier/module-flags-3.ll @@ -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) -- 2.34.1