[LLVMdev] LLD: Returning true on success

Nick Kledzik kledzik at apple.com
Tue Sep 24 13:17:18 PDT 2013

On Sep 24, 2013, at 12:40 PM, Michael Spencer <bigcheesegs at gmail.com> wrote:

> On Tue, Sep 24, 2013 at 12:33 PM, Rui Ueyama <ruiu at google.com> wrote:
> Hi LLD developers,
> I'm about to make a change to invert the return value of Driver::parse() to return true on success. Currently it returns false on success.
> In many other functions, we return true to indicate success and false to indicate failure. The inconsistency is confusing, and fixing it should improve code readability.
> Note that some places in LLVM use false to indicate success, not sure how widespread this is. Personally I think that { if (doSomething()) } means if doSomething succeeded, and thus agree with you. However, I think this is something that needs to be consistent across all of LLVM and should be in the coding standard.

StringRef::getAsInteger() is an example documented to return true if there was an error parsing the string.  

Mapping success/error onto a bool will always be ambiguous.  Is there some better pattern?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130924/7197328f/attachment.html>

More information about the llvm-dev mailing list