[PATCH] D28515: [Support] - Introduce zlib::toString(zlib::Status)

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 00:05:53 PST 2017


grimar added inline comments.


================
Comment at: lib/Support/Compression.cpp:94-95
+    return "";
+  case zlib::StatusUnsupported:
+    return "zlib is unavailable";
+  case zlib::StatusOutOfMemory:
----------------
grimar wrote:
> davide wrote:
> > `isAvailable()` returns always true, so, how can this be ever hit?
> I can imagine some code like next:
> 
> ```
> Status S = zlib::StatusUnsupported;
> if (zlib::isAvailable() {
>   S = ...; //Do something
> }
> 
> if (S != zlib::StatusOK)
>   printError(zlib::toString(S)
> ```
> 
> So it looks can be useful to cover this enum value too.
Ah, my example will not work currently, I see now.
I am thinking about making toString() to have single implementation for cases when HAVE_LIBZ and !HAVE_LIBZ. 
That way example I showed will work and makes sence.


https://reviews.llvm.org/D28515





More information about the llvm-commits mailing list