[lldb] [llvm] [Support] Remove address-extraction methods from DataExtractor (NFC) (PR #190519)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 03:00:09 PDT 2026
================
@@ -22,22 +22,68 @@ namespace llvm {
template <typename Relocator>
class DWARFDataExtractorBase : public DataExtractor {
+ unsigned AddressSize;
public:
DWARFDataExtractorBase(StringRef Data, bool IsLittleEndian,
- uint8_t AddressSize)
- : DataExtractor(Data, IsLittleEndian, AddressSize) {}
+ unsigned AddressSize)
+ : DataExtractor(Data, IsLittleEndian), AddressSize(AddressSize) {}
+
DWARFDataExtractorBase(ArrayRef<uint8_t> Data, bool IsLittleEndian,
- uint8_t AddressSize)
+ unsigned AddressSize)
: DataExtractor(
StringRef(reinterpret_cast<const char *>(Data.data()), Data.size()),
- IsLittleEndian, AddressSize) {}
+ IsLittleEndian),
+ AddressSize(AddressSize) {}
/// Truncating constructor
DWARFDataExtractorBase(const DWARFDataExtractorBase &Other, size_t Length)
: DataExtractor(Other.getData().substr(0, Length), Other.isLittleEndian(),
Other.getAddressSize()) {}
+ /// Get the address size for this extractor.
+ unsigned getAddressSize() const { return AddressSize; }
+
+ /// Set the address size for this extractor.
+ void setAddressSize(unsigned Size) { AddressSize = Size; }
+
+ //------------------------------------------------------------------
+ /// Extract an pointer from \a *offset_ptr.
+ ///
+ /// Extract a single pointer from the data and update the offset
+ /// pointed to by \a offset_ptr. The size of the extracted pointer
+ /// is \a getAddressSize(), so the address size has to be
+ /// set correctly prior to extracting any pointer values.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// @return
+ /// The extracted pointer value as a 64 integer.
+ uint64_t getAddress(uint64_t *offset_ptr) const {
----------------
s-barannikov wrote:
I just moved this code from DataExtractor, bug agreed, this is a good chance to fix coding style issues.
https://github.com/llvm/llvm-project/pull/190519
More information about the llvm-commits
mailing list