aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfoMetadata.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-13 01:07:46 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-13 01:07:46 +0000
commit193a4fdafd9d4d4d6bbb7a1885fb30427434fe97 (patch)
tree1fd83baad32b5aec414d345b99fe39eb88e5fdfb /llvm/lib/IR/DebugInfoMetadata.cpp
parent3b631d291efec2b8b1ef2f20d63e2b31d2bd8254 (diff)
downloadllvm-193a4fdafd9d4d4d6bbb7a1885fb30427434fe97.zip
llvm-193a4fdafd9d4d4d6bbb7a1885fb30427434fe97.tar.gz
llvm-193a4fdafd9d4d4d6bbb7a1885fb30427434fe97.tar.bz2
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/DebugInfoMetadata.cpp')
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index aaf1bc6..46ac98a 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,