r181869 - Use only explicit bool conversion operator

Jordan Rose jordan_rose at apple.com
Wed May 15 09:47:53 PDT 2013


Thanks, David!


On May 15, 2013, at 0:37 , David Blaikie <dblaikie at gmail.com> wrote:

> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h?rev=181869&r1=181868&r2=181869&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h Wed May 15 02:37:26 2013
> @@ -505,7 +505,7 @@ struct ImplicitNullDerefEvent {
> struct DefaultBool {
>   bool val;
>   DefaultBool() : val(false) {}
> -  operator bool() const { return val; }
> +  LLVM_EXPLICIT operator bool() const { return val; }
>   DefaultBool &operator=(bool b) { val = b; return *this; }
> };

I think this one really is supposed to be operator bool() -- it's supposed to behave like "bool with a default constructor" so that the flags are default-initialized, and then you should never have to think of it as anything but bool after that. Although maybe that means it should use operator bool& instead of operator bool, which declares intent a little more.

It's our part of the codebase, so I'm guessing you don't care that much, but do you have an opinion on that?

Jordan

P.S. I didn't ask Ted about the BlkExprStmt and CFGStmtVisitors yet...I'll get to it when we're both in the same room.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130515/2d2bdc47/attachment.html>


More information about the cfe-commits mailing list