diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2015-02-11 09:13:06 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2015-02-11 09:13:06 +0000 |
| commit | d7677e7a8d3bdcce751a37deabe35533a9018759 (patch) | |
| tree | d5645db58d32316dc146424cd3e816e40d52523e /llvm/lib | |
| parent | 1921d3d6f3e916a3031684298d92f5660b182c6b (diff) | |
| download | bcm5719-llvm-d7677e7a8d3bdcce751a37deabe35533a9018759.tar.gz bcm5719-llvm-d7677e7a8d3bdcce751a37deabe35533a9018759.zip | |
Verifier: Check for null operands in !llvm.module.flags
llvm-svn: 228818
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/Module.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/IR/Verifier.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index d32ffcdac33..b0abe8cbe11 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -278,7 +278,7 @@ void Module::eraseNamedMetadata(NamedMDNode *NMD) { } bool Module::isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB) { - if (ConstantInt *Behavior = mdconst::dyn_extract<ConstantInt>(MD)) { + if (ConstantInt *Behavior = mdconst::dyn_extract_or_null<ConstantInt>(MD)) { uint64_t Val = Behavior->getLimitedValue(); if (Val >= ModFlagBehaviorFirstVal && Val <= ModFlagBehaviorLastVal) { MFB = static_cast<ModFlagBehavior>(Val); @@ -298,7 +298,7 @@ getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const { ModFlagBehavior MFB; if (Flag->getNumOperands() >= 3 && isValidModFlagBehavior(Flag->getOperand(0), MFB) && - isa<MDString>(Flag->getOperand(1))) { + dyn_cast_or_null<MDString>(Flag->getOperand(1))) { // Check the operands of the MDNode before accessing the operands. // The verifier will actually catch these failures. MDString *Key = cast<MDString>(Flag->getOperand(1)); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 37816a374cb..5d4de30e440 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -869,7 +869,7 @@ Verifier::visitModuleFlag(const MDNode *Op, Module::ModFlagBehavior MFB; if (!Module::isValidModFlagBehavior(Op->getOperand(0), MFB)) { Assert1( - mdconst::dyn_extract<ConstantInt>(Op->getOperand(0)), + mdconst::dyn_extract_or_null<ConstantInt>(Op->getOperand(0)), "invalid behavior operand in module flag (expected constant integer)", Op->getOperand(0)); Assert1(false, |

