[PATCH] Add ability for can_write to indicate why the file is not writable

Richard Smith richard at metafoo.co.uk
Wed Sep 3 18:36:31 PDT 2014

Hi dblaikie,

Add an optional output parameter to `can_write` to allow it to indicate why a file is not considered writable (along with a sample use from Clang where we currently produce stupid diagnostics saying `"can't open output file: Success"`).

I'm not entirely sure this is the right design, and in particular it's a somewhat different interface from the other functions in this file. I also considered:

  std::error_code can_write(const Twine &Path, bool &result);

... which seems redundant because `result` is set to `true` iff the error code is `success`, and ...

  std::error_code can_write(const Twine &Path);

... which is terrible because `bool(can_write(Path))` is `true` iff the file is *not* writable, and ...

  std::error_code cannot_write(const Twine &Path);

... which is inconsistent with other functions near here and ugly.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5182.13236.patch
Type: text/x-patch
Size: 4294 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140904/ae315699/attachment.bin>

More information about the llvm-commits mailing list