diff options
author | David Blaikie <dblaikie@gmail.com> | 2016-05-23 21:58:58 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2016-05-23 21:58:58 +0000 |
commit | 05e0d2bf5907ec3d2811b447ca9117cd6df529c0 (patch) | |
tree | da2eb8f815f91f944f0f1c579e86b9f130a91c55 /llvm/tools/llvm-dwp/llvm-dwp.cpp | |
parent | 9c81d0fdeb595df5b2c74e5f3385f74a68c6238a (diff) | |
download | bcm5719-llvm-05e0d2bf5907ec3d2811b447ca9117cd6df529c0.tar.gz bcm5719-llvm-05e0d2bf5907ec3d2811b447ca9117cd6df529c0.zip |
llvm-dwp: Pull out compression handling helper
llvm-svn: 270496
Diffstat (limited to 'llvm/tools/llvm-dwp/llvm-dwp.cpp')
-rw-r--r-- | llvm/tools/llvm-dwp/llvm-dwp.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index 1ce6a14d37b..ab66c7168fa 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -359,6 +359,25 @@ std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWO 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, ArrayRef<std::string> Inputs) { 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()) |