DebugInfo: const-qualify accessors of DWARFExpression::Operation

Add `const` to DWARFExpression::Operation's accessors and make
Operation::extract() private, since it's only used by the friend class
DWARFExpression::iterator.
This commit is contained in:
Duncan P. N. Exon Smith 2021-11-15 17:05:09 -08:00
parent b23ba295bd
commit 79df41011b
2 changed files with 17 additions and 12 deletions

View File

@ -86,18 +86,22 @@ public:
uint64_t OperandEndOffsets[2]; uint64_t OperandEndOffsets[2];
public: public:
Description &getDescription() { return Desc; } const Description &getDescription() const { return Desc; }
uint8_t getCode() { return Opcode; } uint8_t getCode() const { return Opcode; }
uint64_t getRawOperand(unsigned Idx) { return Operands[Idx]; } uint64_t getRawOperand(unsigned Idx) const { return Operands[Idx]; }
uint64_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; } uint64_t getOperandEndOffset(unsigned Idx) const {
uint64_t getEndOffset() { return EndOffset; } return OperandEndOffsets[Idx];
bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset, }
Optional<dwarf::DwarfFormat> Format); uint64_t getEndOffset() const { return EndOffset; }
bool isError() { return Error; } bool isError() const { return Error; }
bool print(raw_ostream &OS, DIDumpOptions DumpOpts, bool print(raw_ostream &OS, DIDumpOptions DumpOpts,
const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, const DWARFExpression *Expr, const MCRegisterInfo *RegInfo,
DWARFUnit *U, bool isEH); DWARFUnit *U, bool isEH) const;
bool verify(DWARFUnit *U); bool verify(DWARFUnit *U);
private:
bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset,
Optional<dwarf::DwarfFormat> Format);
}; };
/// An iterator to go through the expression operations. /// An iterator to go through the expression operations.

View File

@ -207,7 +207,8 @@ bool DWARFExpression::Operation::extract(DataExtractor Data,
} }
static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS, static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS,
DIDumpOptions DumpOpts, uint64_t Operands[2], DIDumpOptions DumpOpts,
const uint64_t Operands[2],
unsigned Operand) { unsigned Operand) {
assert(Operand < 2 && "operand out of bounds"); assert(Operand < 2 && "operand out of bounds");
auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]); auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
@ -226,7 +227,7 @@ static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS,
static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS,
DIDumpOptions DumpOpts, uint8_t Opcode, DIDumpOptions DumpOpts, uint8_t Opcode,
uint64_t Operands[2], const uint64_t Operands[2],
const MCRegisterInfo *MRI, bool isEH) { const MCRegisterInfo *MRI, bool isEH) {
if (!MRI) if (!MRI)
return false; return false;
@ -262,7 +263,7 @@ static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS,
bool DWARFExpression::Operation::print(raw_ostream &OS, DIDumpOptions DumpOpts, bool DWARFExpression::Operation::print(raw_ostream &OS, DIDumpOptions DumpOpts,
const DWARFExpression *Expr, const DWARFExpression *Expr,
const MCRegisterInfo *RegInfo, const MCRegisterInfo *RegInfo,
DWARFUnit *U, bool isEH) { DWARFUnit *U, bool isEH) const {
if (Error) { if (Error) {
OS << "<decoding error>"; OS << "<decoding error>";
return false; return false;