[cfe-dev] if (p == nullptr) style conventions?

Sean Silva chisophugis at gmail.com
Tue May 26 14:14:05 PDT 2015

I personally find `if (p)` easy to grok, but for whatever reason I haven't
internalized the `if (!p)` pattern; I always have to think twice about `if
(!p)` and mentally expand it into `if ((!p) != 0)` and simplify to find `if
(p == 0)`. Just my weirdness probably.

-- Sean Silva

2015-05-24 10:52 GMT-07:00 Richard <legalize at xmission.com>:

> Does LLVM/clang have any style convention preferring:
> if (p)
> over
> if (p != nullptr)
> ?
> or it's converse:
> if (!p)
> over
> if (p == nullptr)
> ?
> I didn't find anything in the existing style guide and I've gotten
> a request for readability-simplify-boolean-expr in clang-tidy to
> make such simplifications.
> PS: Mail filters are blocking my messages, so ignore this, its
> only for them.  Lorem ipsum dolor sit amet, consectetur adipiscing
> elit. Phasellus consequat ullamcorper mollis. Sed blandit semper tortor
> ultricies dictum. Proin hendrerit et quam in sagittis. Maecenas vel
> blandit ante, in auctor sem.  Phasellus condimentum leo vel finibus
> viverra. Duis fermentum sollicitudin est, ac iaculis lectus auctor vel.
> Nam condimentum nulla feugiat, venenatis nibh a, elementum nulla. Nulla
> vitae malesuada eros. Nulla cursus maximus ligula non hendrerit.
> Curabitur lobortis nulla vel sapien posuere, id aliquam orci
> bibendum. Vestibulum at vulputate risus. Proin in purus commodo,
> tempus lectus vitae, faucibus nunc. Aenean congue faucibus elit, sit
> amet facilisis nibh ultrices eget. Nam pulvinar leo ac nunc ultricies,
> nec tincidunt nulla tincidunt. Etiam placerat felis tellus, ut ultricies
> nunc ultricies quis. In placerat sapien nec ultricies mattis. Integer
> sed tempor orci, ac imperdiet orci. Integer ac augue et augue convallis
> faucibus.
> --
> "The Direct3D Graphics Pipeline" free book <
> http://tinyurl.com/d3d-pipeline>
>      The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
>          The Terminals Wiki <http://terminals.classiccmp.org>
>   Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150526/ba84c4c9/attachment.html>

More information about the cfe-dev mailing list