This is an archive of the discontinued LLVM Phabricator instance.

Add ability for can_write to indicate why the file is not writable
Needs ReviewPublic

Authored by rsmith on Sep 3 2014, 6:36 PM.

Details

Summary

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.

Diff Detail

Event Timeline

rsmith updated this revision to Diff 13236.Sep 3 2014, 6:36 PM
rsmith retitled this revision from to Add ability for can_write to indicate why the file is not writable.
rsmith updated this object.
rsmith edited the test plan for this revision. (Show Details)
rsmith added a reviewer: dblaikie.
rsmith set the repository for this revision to rL LLVM.
rsmith added reviewers: rafael, Bigcheese.
rsmith added a subscriber: Unknown Object (MLST).
rafael edited edge metadata.Sep 11 2014, 10:49 AM
  • Don't use can_write.
  • Change both exists and can_write to "std::error_code access(const

Twine &Path, SomeEnum Mode)".

  • Change can_write to "std::error_code write_access(const Twine &Path)".

There is also can_write. OK, I will give it a try at merging these.

Cheers,
Rafael

espindola edited reviewers, added: espindola; removed: rafael.Mar 15 2018, 11:04 AM