From 12d17f4375df43c6d3ca16dfb7bfe2accbc9d4d4 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 25 May 2014 20:26:33 +0000 Subject: [PATCH] tools: use references rather than out pointers in COFFDumper Switch to use references for parameters that are guaranteed to be non-null. Simplifies the code a slight bit in preparation for another change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209603 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-readobj/COFFDumper.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 188e9f891339..aec41c7d2ab2 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -80,11 +80,8 @@ class COFFDumper : public ObjDumper { void cacheRelocations(); - error_code getSection( - const std::vector &Rels, - uint64_t Offset, - const coff_section **Section, - uint64_t *AddrPtr); + error_code getSection(const std::vector &Rels, uint64_t Offset, + const coff_section *&Section, uint64_t &AddrPtr); typedef DenseMap > RelocMapTy; @@ -460,24 +457,17 @@ static std::string formatSymbol(const std::vector &Rels, return Str.str(); } -error_code COFFDumper::getSection( - const std::vector &Rels, uint64_t Offset, - const coff_section **SectionPtr, uint64_t *AddrPtr) { - +error_code COFFDumper::getSection(const std::vector &Rels, + uint64_t Offset, + const coff_section *&SectionPtr, + uint64_t &AddrPtr) { SymbolRef Sym; if (error_code EC = resolveSymbol(Rels, Offset, Sym)) return EC; - const coff_section *Section; - uint64_t Addr; - if (error_code EC = resolveSectionAndAddress(Obj, Sym, Section, Addr)) + if (error_code EC = resolveSectionAndAddress(Obj, Sym, SectionPtr, AddrPtr)) return EC; - if (SectionPtr) - *SectionPtr = Section; - if (AddrPtr) - *AddrPtr = Addr; - return object_error::success; } @@ -1063,7 +1053,7 @@ void COFFDumper::printRuntimeFunction( const coff_section* XData = nullptr; uint64_t UnwindInfoOffset = 0; - if (error(getSection(Rels, OffsetInSection + 8, &XData, &UnwindInfoOffset))) + if (error(getSection(Rels, OffsetInSection + 8, XData, UnwindInfoOffset))) return; ArrayRef XContents;