[llvm] r210100 - Add operator== and operator!= to compare with nullptr.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jun 3 08:16:26 PDT 2014


On 3 June 2014 11:03, David Blaikie <dblaikie at gmail.com> wrote:
> Unit tests? (I say this in part because I recall giving Chris Lattner some
> grief over a similar change (that turned out to be buggy...))

I honestly don't see the point. I am as able to implement a broken
test as I am to implement a broken ==. The unit test just makes it
harder to notice what code is dead and to refactor APIs.

IMHO Unit tests are incredible valuable when
* The implementation is not easily accessible from higher level tests.
* The semantics are much simpler than the implementation. Things like
removing an element from a set and then checking it is not there.

In this case as you pointed out in the other thread, the correct fix
is probably to switch to std::shared_ptr anyway.

> And if you're going to define some operators in terms of others you could do
> that for all and implement A == nullptr as nullptr == A

I like this one.  r210107.

Cheers,
Rafael



More information about the llvm-commits mailing list