summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfoMetadata.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-07-06 21:06:20 +0000
committerVedant Kumar <vsk@apple.com>2018-07-06 21:06:20 +0000
commit8a3680852e41a10d96fe301b29c856fb63904eda (patch)
tree01e1ca659916bc1a45f08a816e2f8f85d9bdb90a /llvm/lib/IR/DebugInfoMetadata.cpp
parent648bebdc67f6dffa7de4b7bfe028498357ebf74d (diff)
downloadbcm5719-llvm-8a3680852e41a10d96fe301b29c856fb63904eda.tar.gz
bcm5719-llvm-8a3680852e41a10d96fe301b29c856fb63904eda.zip
Remove a redundant null-check in DIExpression::prepend, NFC
Code outside of an `if (Expr)` block dereferenced `Expr`, so the null check was redundant. llvm-svn: 336465
Diffstat (limited to 'llvm/lib/IR/DebugInfoMetadata.cpp')
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 13455ee4805..54062e2138b 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -819,24 +819,25 @@ DIExpression *DIExpression::prepend(const DIExpression *Expr, bool DerefBefore,
DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr,
SmallVectorImpl<uint64_t> &Ops,
bool StackValue) {
+ assert(Expr && "Can't prepend ops to this expression");
+
// If there are no ops to prepend, do not even add the DW_OP_stack_value.
if (Ops.empty())
StackValue = false;
- if (Expr)
- for (auto Op : Expr->expr_ops()) {
- // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
- if (StackValue) {
- if (Op.getOp() == dwarf::DW_OP_stack_value)
- StackValue = false;
- else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
- Ops.push_back(dwarf::DW_OP_stack_value);
- StackValue = false;
- }
+ for (auto Op : Expr->expr_ops()) {
+ // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
+ if (StackValue) {
+ if (Op.getOp() == dwarf::DW_OP_stack_value)
+ StackValue = false;
+ else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
+ Ops.push_back(dwarf::DW_OP_stack_value);
+ StackValue = false;
}
- Ops.push_back(Op.getOp());
- for (unsigned I = 0; I < Op.getNumArgs(); ++I)
- Ops.push_back(Op.getArg(I));
}
+ Ops.push_back(Op.getOp());
+ for (unsigned I = 0; I < Op.getNumArgs(); ++I)
+ Ops.push_back(Op.getArg(I));
+ }
if (StackValue)
Ops.push_back(dwarf::DW_OP_stack_value);
return DIExpression::get(Expr->getContext(), Ops);
OpenPOWER on IntegriCloud