From bd402fc3f3e832395b89dda4a9b8392c6b0dd6fa Mon Sep 17 00:00:00 2001 From: James Henderson Date: Fri, 20 Dec 2019 14:30:31 +0000 Subject: [PATCH] [DebugInfo][NFC] Use function_ref consistently in debug line parsing This patch fixes an inconsistency where we were using std::function in some places and function_ref in others to pass around the error handling callback. Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D71762 --- llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h | 2 +- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h | 17 ++++++++--------- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 2 +- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h index f0896b1..a2a10d2 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -298,7 +298,7 @@ public: /// Report any recoverable parsing problems using the callback. Expected getLineTableForUnit(DWARFUnit *U, - std::function RecoverableErrorCallback); + function_ref RecoverableErrorCallback); DataExtractor getStringExtractor() const { return DataExtractor(DObj->getStrSection(), false, 0); diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h index c2be830..d5b6c72 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -280,11 +280,10 @@ public: void clear(); /// Parse prologue and all rows. - Error parse( - DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, - const DWARFContext &Ctx, const DWARFUnit *U, - std::function RecoverableErrorCallback, - raw_ostream *OS = nullptr); + Error parse(DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, + const DWARFContext &Ctx, const DWARFUnit *U, + function_ref RecoverableErrorCallback, + raw_ostream *OS = nullptr); using RowVector = std::vector; using RowIter = RowVector::const_iterator; @@ -309,10 +308,10 @@ public: }; const LineTable *getLineTable(uint64_t Offset) const; - Expected getOrParseLineTable( - DWARFDataExtractor &DebugLineData, uint64_t Offset, - const DWARFContext &Ctx, const DWARFUnit *U, - std::function RecoverableErrorCallback); + Expected + getOrParseLineTable(DWARFDataExtractor &DebugLineData, uint64_t Offset, + const DWARFContext &Ctx, const DWARFUnit *U, + function_ref RecoverableErrorCallback); /// Helper to allow for parsing of an entire .debug_line section in sequence. class SectionParser { diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index e452c76..aaa6d52 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -874,7 +874,7 @@ DWARFContext::getLineTableForUnit(DWARFUnit *U) { } Expected DWARFContext::getLineTableForUnit( - DWARFUnit *U, std::function RecoverableErrorCallback) { + DWARFUnit *U, function_ref RecoverableErrorCallback) { if (!Line) Line.reset(new DWARFDebugLine); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index cf31f5e..8892739 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -514,7 +514,7 @@ DWARFDebugLine::getLineTable(uint64_t Offset) const { Expected DWARFDebugLine::getOrParseLineTable( DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx, - const DWARFUnit *U, std::function RecoverableErrorCallback) { + const DWARFUnit *U, function_ref RecoverableErrorCallback) { if (!DebugLineData.isValidOffset(Offset)) return createStringError(errc::invalid_argument, "offset 0x%8.8" PRIx64 " is not a valid debug line section offset", @@ -535,7 +535,7 @@ Expected DWARFDebugLine::getOrParseLineTable( Error DWARFDebugLine::LineTable::parse( DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U, - std::function RecoverableErrorCallback, raw_ostream *OS) { + function_ref RecoverableErrorCallback, raw_ostream *OS) { const uint64_t DebugLineOffset = *OffsetPtr; clear(); -- 2.7.4