diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-13 01:07:46 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-13 01:07:46 +0000 |
| commit | 193a4fdafd9d4d4d6bbb7a1885fb30427434fe97 (patch) | |
| tree | 1fd83baad32b5aec414d345b99fe39eb88e5fdfb /llvm/lib/IR | |
| parent | 3b631d291efec2b8b1ef2f20d63e2b31d2bd8254 (diff) | |
| download | bcm5719-llvm-193a4fdafd9d4d4d6bbb7a1885fb30427434fe97.tar.gz bcm5719-llvm-193a4fdafd9d4d4d6bbb7a1885fb30427434fe97.zip | |
IR: Add MDExpression::ExprOperand
Port `DIExpression::Operand` over to `MDExpression::ExprOperand`. The
logic is needed directly in `MDExpression` to support printing in
assembly.
llvm-svn: 229002
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/DebugInfoMetadata.cpp | 32 | ||||
| -rw-r--r-- | llvm/lib/IR/Verifier.cpp | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index aaf1bc6e1ab..46ac98a7d0c 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -350,6 +350,38 @@ MDExpression *MDExpression::getImpl(LLVMContext &Context, DEFINE_GETIMPL_STORE_NO_OPS(MDExpression, (Elements)); } +unsigned MDExpression::ExprOperand::getSize() const { + switch (getOp()) { + case dwarf::DW_OP_bit_piece: + return 3; + case dwarf::DW_OP_plus: + return 2; + default: + return 1; + } +} + +bool MDExpression::isValid() const { + for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) { + // Check that there's space for the operand. + if (I->get() + I->getSize() > E->get()) + return false; + + // Check that the operand is valid. + switch (I->getOp()) { + default: + return false; + case dwarf::DW_OP_bit_piece: + // Piece expressions must be at the end. + return I->get() + I->getSize() == E->get(); + case dwarf::DW_OP_plus: + case dwarf::DW_OP_deref: + break; + } + } + return true; +} + MDObjCProperty *MDObjCProperty::getImpl( LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line, MDString *GetterName, MDString *SetterName, unsigned Attributes, diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5d4de30e440..22a5a9620b0 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -780,6 +780,7 @@ void Verifier::visitMDLocalVariable(const MDLocalVariable &N) { void Verifier::visitMDExpression(const MDExpression &N) { Assert1(N.getTag() == dwarf::DW_TAG_expression, "invalid tag", &N); + Assert1(N.isValid(), "invalid expression", &N); } void Verifier::visitMDObjCProperty(const MDObjCProperty &N) { |

