[PATCH] D28515: [Support] - Introduce zlib::toString(zlib::Status)
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 10 05:53:00 PST 2017
grimar created this revision.
grimar added reviewers: rafael, davide.
grimar added subscribers: llvm-commits, grimar, evgeny777.
Helper is useful for universal error messages
when using zlib functionality.
I plan to use it in https://reviews.llvm.org/D28105 or following patch for
better uncompression errors diagnostic output.
https://reviews.llvm.org/D28515
Files:
include/llvm/Support/Compression.h
lib/Support/Compression.cpp
Index: lib/Support/Compression.cpp
===================================================================
--- lib/Support/Compression.cpp
+++ lib/Support/Compression.cpp
@@ -87,6 +87,25 @@
return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
}
+StringRef zlib::toString(zlib::Status Stat) {
+ switch (Stat) {
+ case zlib::StatusOK:
+ return "";
+ case zlib::StatusUnsupported:
+ return "zlib is unavailable";
+ case zlib::StatusOutOfMemory:
+ return "there was not enough memory";
+ case zlib::StatusBufferTooShort:
+ return "there was not enough room in the output buffer";
+ case zlib::StatusInvalidArg:
+ return "invalid input parameter";
+ case zlib::StatusInvalidData:
+ return "data was corrupted or incomplete";
+ default:
+ llvm_unreachable("zlib status unknown");
+ }
+}
+
#else
bool zlib::isAvailable() { return false; }
zlib::Status zlib::compress(StringRef InputBuffer,
@@ -106,5 +125,8 @@
uint32_t zlib::crc32(StringRef Buffer) {
llvm_unreachable("zlib::crc32 is unavailable");
}
+StringRef zlib::toString(zlib::Status Stat) {
+ llvm_unreachable("zlib::toString is unavailable");
+}
#endif
Index: include/llvm/Support/Compression.h
===================================================================
--- include/llvm/Support/Compression.h
+++ include/llvm/Support/Compression.h
@@ -52,6 +52,8 @@
uint32_t crc32(StringRef Buffer);
+StringRef toString(Status Stat);
+
} // End of namespace zlib
} // End of namespace llvm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28515.83802.patch
Type: text/x-patch
Size: 1499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170110/212bc3d2/attachment.bin>
More information about the llvm-commits
mailing list