[llvm] r270496 - llvm-dwp: Pull out compression handling helper
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon May 23 14:58:58 PDT 2016
Author: dblaikie
Date: Mon May 23 16:58:58 2016
New Revision: 270496
URL: http://llvm.org/viewvc/llvm-project?rev=270496&view=rev
Log:
llvm-dwp: Pull out compression handling helper
Modified:
llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=270496&r1=270495&r2=270496&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Mon May 23 16:58:58 2016
@@ -359,6 +359,25 @@ std::string buildDWODescription(StringRe
return Text;
}
+static Error handleCompressedSection(
+ SmallVector<SmallString<32>, 4> &UncompressedSections, StringRef &Name,
+ StringRef &Contents) {
+ if (!Name.startswith("zdebug_"))
+ return Error();
+ UncompressedSections.emplace_back();
+ uint64_t OriginalSize;
+ if (!zlib::isAvailable())
+ return make_error<DWPError>("zlib not available");
+ if (!consumeCompressedDebugSectionHeader(Contents, OriginalSize) ||
+ zlib::uncompress(Contents, UncompressedSections.back(), OriginalSize) !=
+ zlib::StatusOK)
+ return make_error<DWPError>(
+ ("failure while decompressing compressed section: '" + Name + "\'")
+ .str());
+ Name = Name.substr(1);
+ Contents = UncompressedSections.back();
+ return Error();
+}
Error buildDuplicateError(const std::pair<uint64_t, UnitIndexEntry> &PrevE,
const CompileUnitIdentifiers &ID, StringRef DWPName) {
return make_error<DWPError>(
@@ -431,21 +450,9 @@ static Error write(MCStreamer &Out, Arra
if (auto Err = Section.getContents(Contents))
return errorCodeToError(Err);
- if (Name.startswith("zdebug_")) {
- UncompressedSections.emplace_back();
- uint64_t OriginalSize;
- if (!zlib::isAvailable())
- return make_error<DWPError>("zlib not available");
- if (!consumeCompressedDebugSectionHeader(Contents, OriginalSize) ||
- zlib::uncompress(Contents, UncompressedSections.back(),
- OriginalSize) != zlib::StatusOK)
- return make_error<DWPError>(
- ("failure while decompressing compressed section: '" + Name +
- "\'")
- .str());
- Name = Name.substr(1);
- Contents = UncompressedSections.back();
- }
+ if (auto Err =
+ handleCompressedSection(UncompressedSections, Name, Contents))
+ return Err;
auto SectionPair = KnownSections.find(Name);
if (SectionPair == KnownSections.end())
More information about the llvm-commits
mailing list