r181869 - Use only explicit bool conversion operator

David Blaikie dblaikie at gmail.com
Wed May 15 10:02:24 PDT 2013


On Wed, May 15, 2013 at 9:47 AM, Jordan Rose <jordan_rose at apple.com> wrote:

> 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.
>

Oh, totally fair point - as you might've guessed I did this mechanically
(with sed). I only really gave types a second thought when I found
compilation errors at usage sites that looked like they should stay written
the way they were. I don't think I came across any compilation
errors/callsites that had to be fixed for this type, so I didn't give it
any consideration.

Feel free to change it back. Maybe add a /* implicit */ comment like we do
for deliberately implicit conversion operators.


> 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?
>

Yeah, this wasn't a project with any particularly self-centered need, just
some general cleanup without much nuance/consideration for specific parts
of the codebase, etc.


> 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.
>

Sure thing - thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130515/5a24a687/attachment.html>


More information about the cfe-commits mailing list