From c6ac80b70108edb2d04b6da306e81724eb3df5cb Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Tue, 7 Apr 2015 03:49:59 +0000 Subject: [PATCH] DebugInfo: Move DIExpression bit-piece API to MDExpression git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234286 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DebugInfo.h | 13 +++---------- include/llvm/IR/DebugInfoMetadata.h | 9 +++++++++ lib/IR/DebugInfo.cpp | 15 --------------- lib/IR/DebugInfoMetadata.cpp | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index c2ad4e01e7c..bfb725f65bc 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -860,18 +860,11 @@ public: return *get(); } - /// \brief Return the number of elements in the complex expression. unsigned getNumElements() const { return get()->getNumElements(); } - - /// \brief return the Idx'th complex address element. uint64_t getElement(unsigned I) const { return get()->getElement(I); } - - /// \brief Return whether this is a piece of an aggregate variable. - bool isBitPiece() const; - /// \brief Return the offset of this piece in bits. - uint64_t getBitPieceOffset() const; - /// \brief Return the size of this piece in bits. - uint64_t getBitPieceSize() const; + bool isBitPiece() const { return get()->isBitPiece(); } + uint64_t getBitPieceOffset() const { return get()->getBitPieceOffset(); } + uint64_t getBitPieceSize() const { return get()->getBitPieceSize(); } }; /// \brief This object holds location information. diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index 2bac0ac8e86..d4dff68911e 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -1831,6 +1831,15 @@ public: return Elements[I]; } + /// \brief Return whether this is a piece of an aggregate variable. + bool isBitPiece() const; + + /// \brief Return the offset of this piece in bits. + uint64_t getBitPieceOffset() const; + + /// \brief Return the size of this piece in bits. + uint64_t getBitPieceSize() const; + typedef ArrayRef::iterator element_iterator; element_iterator elements_begin() const { return getElements().begin(); } element_iterator elements_end() const { return getElements().end(); } diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index ce83faad495..138df05ea4a 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -65,21 +65,6 @@ unsigned DIVariable::getSizeInBits(const DITypeIdentifierMap &Map) { return Ty.getSizeInBits(); } -bool DIExpression::isBitPiece() const { - unsigned N = getNumElements(); - return N >=3 && getElement(N-3) == dwarf::DW_OP_bit_piece; -} - -uint64_t DIExpression::getBitPieceOffset() const { - assert(isBitPiece() && "not a piece"); - return getElement(getNumElements()-2); -} - -uint64_t DIExpression::getBitPieceSize() const { - assert(isBitPiece() && "not a piece"); - return getElement(getNumElements()-1); -} - //===----------------------------------------------------------------------===// // Simple Descriptor Constructors and other Methods //===----------------------------------------------------------------------===// diff --git a/lib/IR/DebugInfoMetadata.cpp b/lib/IR/DebugInfoMetadata.cpp index 190a31d5551..6ce091f54d1 100644 --- a/lib/IR/DebugInfoMetadata.cpp +++ b/lib/IR/DebugInfoMetadata.cpp @@ -445,6 +445,24 @@ bool MDExpression::isValid() const { return true; } +bool MDExpression::isBitPiece() const { + assert(isValid() && "Expected valid expression"); + if (unsigned N = getNumElements()) + if (N >= 3) + return getElement(N - 3) == dwarf::DW_OP_bit_piece; + return false; +} + +uint64_t MDExpression::getBitPieceOffset() const { + assert(isBitPiece() && "Expected bit piece"); + return getElement(getNumElements() - 2); +} + +uint64_t MDExpression::getBitPieceSize() const { + assert(isBitPiece() && "Expected bit piece"); + return getElement(getNumElements() - 1); +} + MDObjCProperty *MDObjCProperty::getImpl( LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line, MDString *GetterName, MDString *SetterName, unsigned Attributes,