[LLVMdev] LLD: Returning true on success

Chandler Carruth chandlerc at google.com
Tue Sep 24 17:21:37 PDT 2013

On Tue, Sep 24, 2013 at 6:07 PM, Sean Silva <chisophugis at gmail.com> wrote:

> I think it makes a lot of sense in this case. The idea is that you
> increase indentation in the "error" case.

I vehemently disagree.

Use the return value and type that make sense for the ABI and will be
unsurprising when reading the code. Use a ! when you need to produce
early-exit code flows.

A note about error objects: you should always have a variable and/or type
name here. This gives you the opportunity to make it perfectly unambiguous
whether it was an error or success. The example I give is std::error_code:

if (std::error_code ec = some_filesystem_operation(...)) {
  /* unambiguously have an error code, because the condition was on the
error code, not the function */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130924/7f2d5c1f/attachment.html>

More information about the llvm-dev mailing list