From 79df41011ba6b899c50f870bad4b28dbbb0d28cb Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 15 Nov 2021 17:05:09 -0800 Subject: [PATCH] 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. --- .../llvm/DebugInfo/DWARF/DWARFExpression.h | 22 +++++++++++-------- llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp | 7 +++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h index 9ebe9b0e4110..1be990692c3c 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h @@ -86,18 +86,22 @@ public: uint64_t OperandEndOffsets[2]; public: - Description &getDescription() { return Desc; } - uint8_t getCode() { return Opcode; } - uint64_t getRawOperand(unsigned Idx) { return Operands[Idx]; } - uint64_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; } - uint64_t getEndOffset() { return EndOffset; } - bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset, - Optional Format); - bool isError() { return Error; } + const Description &getDescription() const { return Desc; } + uint8_t getCode() const { return Opcode; } + uint64_t getRawOperand(unsigned Idx) const { return Operands[Idx]; } + uint64_t getOperandEndOffset(unsigned Idx) const { + return OperandEndOffsets[Idx]; + } + uint64_t getEndOffset() const { return EndOffset; } + bool isError() const { return Error; } bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, - DWARFUnit *U, bool isEH); + DWARFUnit *U, bool isEH) const; bool verify(DWARFUnit *U); + + private: + bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset, + Optional Format); }; /// An iterator to go through the expression operations. diff --git a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp index 4b9be85f6885..0b431afeb1b6 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp @@ -207,7 +207,8 @@ bool DWARFExpression::Operation::extract(DataExtractor Data, } static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS, - DIDumpOptions DumpOpts, uint64_t Operands[2], + DIDumpOptions DumpOpts, + const uint64_t Operands[2], unsigned Operand) { assert(Operand < 2 && "operand out of bounds"); 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, DIDumpOptions DumpOpts, uint8_t Opcode, - uint64_t Operands[2], + const uint64_t Operands[2], const MCRegisterInfo *MRI, bool isEH) { if (!MRI) return false; @@ -262,7 +263,7 @@ static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, bool DWARFExpression::Operation::print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, - DWARFUnit *U, bool isEH) { + DWARFUnit *U, bool isEH) const { if (Error) { OS << ""; return false;