[PATCH] D39203: [raw_fd_ostream] report actual error in error messages

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 12:56:32 PDT 2017


inglorion added a comment.

As an alternative, I considered using an Error instead of an error_code. I decided against that, because

- It produces a riskier change. Error.h depends on raw_ostream.h, and now we would also have an edge going the other way. Working around this is possible, but can affect clients that depend on Error.h, of which there are many.
- It changes the semantics from unchecked errors resulting in fatals to unchecked errors *or successes* resulting in fatals. This could be worked around, but it would make the change larger comparing to just using a type that already provides compatible semantics.
- raw_ostream et al. are meant to look like standard C++ types. std::error_code is arguably a better fit for that than llvm::Error.
- The code that raw_fd_ostream calls already produces error_codes, so by just using those, we avoid having to convert them to Error.

In short, std::error_code makes for a simpler, less risky change that fits with the existing code and semantics, so I chose to go with that.


https://reviews.llvm.org/D39203





More information about the llvm-commits mailing list