aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugProgramInstruction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/DebugProgramInstruction.cpp')
-rw-r--r--llvm/lib/IR/DebugProgramInstruction.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp
index 362d467beeb1..5d2189b54204 100644
--- a/llvm/lib/IR/DebugProgramInstruction.cpp
+++ b/llvm/lib/IR/DebugProgramInstruction.cpp
@@ -473,11 +473,12 @@ DbgLabelRecord::createDebugIntrinsic(Module *M,
Value *DbgVariableRecord::getAddress() const {
auto *MD = getRawAddress();
- if (auto *V = dyn_cast<ValueAsMetadata>(MD))
+ if (auto *V = dyn_cast_or_null<ValueAsMetadata>(MD))
return V->getValue();
// When the value goes to null, it gets replaced by an empty MDNode.
- assert(!cast<MDNode>(MD)->getNumOperands() && "Expected an empty MDNode");
+ assert(!MD ||
+ !cast<MDNode>(MD)->getNumOperands() && "Expected an empty MDNode");
return nullptr;
}