diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp --- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp +++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp @@ -509,12 +509,8 @@ if (Error Err = replaceDebugSections( Obj, isCompressable, [&Config, &Obj](const SectionBase *S) -> Expected { - Expected NewSection = - CompressedSection::create(*S, Config.CompressionType); - if (!NewSection) - return NewSection.takeError(); - - return &Obj.addSection(std::move(*NewSection)); + return &Obj.addSection( + CompressedSection(*S, Config.CompressionType)); })) return Err; } else if (Config.DecompressDebugSections) { diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.h b/llvm/lib/ObjCopy/ELF/ELFObject.h --- a/llvm/lib/ObjCopy/ELF/ELFObject.h +++ b/llvm/lib/ObjCopy/ELF/ELFObject.h @@ -542,11 +542,10 @@ SmallVector CompressedData; public: - static Expected - create(const SectionBase &Sec, DebugCompressionType CompressionType); - static Expected create(ArrayRef CompressedData, - uint64_t DecompressedSize, - uint64_t DecompressedAlign); + CompressedSection(const SectionBase &Sec, + DebugCompressionType CompressionType); + CompressedSection(ArrayRef CompressedData, uint64_t DecompressedSize, + uint64_t DecompressedAlign); uint64_t getDecompressedSize() const { return DecompressedSize; } uint64_t getDecompressedAlign() const { return DecompressedAlign; } @@ -558,12 +557,6 @@ return (S->OriginalFlags & ELF::SHF_COMPRESSED) || (StringRef(S->Name).startswith(".zdebug")); } - -private: - CompressedSection(const SectionBase &Sec, - DebugCompressionType CompressionType); - CompressedSection(ArrayRef CompressedData, uint64_t DecompressedSize, - uint64_t DecompressedAlign); }; class DecompressedSection : public SectionBase { diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp --- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp +++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp @@ -545,18 +545,6 @@ return Error::success(); } -Expected -CompressedSection::create(const SectionBase &Sec, - DebugCompressionType CompressionType) { - return CompressedSection(Sec, CompressionType); -} -Expected -CompressedSection::create(ArrayRef CompressedData, - uint64_t DecompressedSize, - uint64_t DecompressedAlign) { - return CompressedSection(CompressedData, DecompressedSize, DecompressedAlign); -} - CompressedSection::CompressedSection(const SectionBase &Sec, DebugCompressionType CompressionType) : SectionBase(Sec), CompressionType(CompressionType), @@ -1754,12 +1742,8 @@ uint64_t DecompressedSize, DecompressedAlign; std::tie(DecompressedSize, DecompressedAlign) = getDecompressedSizeAndAlignment(*Data); - Expected NewSection = - CompressedSection::create(*Data, DecompressedSize, DecompressedAlign); - if (!NewSection) - return NewSection.takeError(); - - return Obj.addSection(std::move(*NewSection)); + return Obj.addSection( + CompressedSection(*Data, DecompressedSize, DecompressedAlign)); } return Obj.addSection
(*Data);