Coding standard: return succ on failure?

Chris Lattner clattner at apple.com
Fri Aug 2 15:13:11 PDT 2013


On Aug 2, 2013, at 7:16 AM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:

> On 1 August 2013 16:25, Chandler Carruth <chandlerc at google.com> wrote:
>> I have lobbied in the past for doing away with returning false on success. I
>> continue to do so.
>> 
>> There are parts of the Clang parser that do this consistently, but they are
>> increasingly few and far between. I consistently see new code being written
>> in both Clang and LLVM using false to mean failure and true to mean success,
>> so I think we should just admit that this is the de-facto standard for new
>> code going forward.
>> 
>> That said, the last time I raised this question, Chris showed up to argue.
>> ;]
> 
> ccing him :-)
> 
> One think I like with returning true on failure is that
> 
> bool doFooBar();


I generally prefer "true" to be failure, specifically for cases like the clang parser.  However, arguably all of these should switch to some enum type instead of using true/false, which have no logical tie in to success or failure.

Overall, I don't have a strong opinion. 

-Chris






More information about the llvm-commits mailing list