[PATCH] D28684: [Support/Compression] - Change zlib API to return Error instead of custom status.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 16 01:17:20 PST 2017


>> -zlib::Status zlib::compress(StringRef InputBuffer,
>> -                            SmallVectorImpl<char> &CompressedBuffer,
>> -                            CompressionLevel Level) {
>> -  return zlib::StatusUnsupported;
>> -}
>> -zlib::Status zlib::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
>> -                              size_t &UncompressedSize) {
>> -  return zlib::StatusUnsupported;
>> -}
>> -zlib::Status zlib::uncompress(StringRef InputBuffer,
>> -                              SmallVectorImpl<char> &UncompressedBuffer,
>> -                              size_t UncompressedSize) {
>> -  return zlib::StatusUnsupported;
>> +Error zlib::compress(StringRef InputBuffer,
>> +                     SmallVectorImpl<char> &CompressedBuffer,
>> +                     CompressionLevel Level) {
>> +  llvm_unreachable("zlib::compress is unavailable");
>> +}
>> +Error zlib::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
>> +                       size_t &UncompressedSize) {
>> +  llvm_unreachable("zlib::uncompress is unavailable");
>> +}
>> +Error zlib::uncompress(StringRef InputBuffer,
>> +                       SmallVectorImpl<char> &UncompressedBuffer,
>> +                       size_t UncompressedSize) {
>> +  llvm_unreachable("zlib::uncompress is unavailable");
>
>Why are these unreachable now?
>
>Cheers,
>Rafael

I think these were always unused and never called in case when zlib::Available() == false.
And at the same time zlib::crc32() already was implemented as unreachable:

uint32_t zlib::crc32(StringRef Buffer) {
  llvm_unreachable("zlib::crc32 is unavailable");
}

So I think it is reasonable to allow calling these methods only under "if (zlib::Available())" condition
instead of making them to return some new string error "zlib is unavailable", which probably
not really usefull.

George.


More information about the llvm-commits mailing list