Page MenuHomePhabricator

[ADT] 'PointerUnion::is' returns 'bool'

Authored by modocache on Feb 1 2020, 12:35 PM.



The return type of 'PointerUnion::is' has been 'int' since it was first
added in March 2009, in SVN r67987, or

The only other change to this member function was a clang-format applied
in December 2015, in SVN r256513, or

However, since the return value is the result of a == comparison, an
implicit cast must be made converting the boolean result to an int.
Change the return type to bool to remove the need for such a cast.

Test Plan:
I ran llvm-project check-all under ASAN, no failures were reported
(other than obviously unrelated tests that were already failing in
ASAN buildbots).

Diff Detail

Event Timeline

modocache created this revision.Feb 1 2020, 12:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2020, 12:35 PM
Herald added a subscriber: dexonsmith. · View Herald Transcript
dblaikie accepted this revision.Feb 1 2020, 1:26 PM

Sounds good to me. (I guess this was motivated by some warning or other experimental bug finding type thing?)

This revision is now accepted and ready to land.Feb 1 2020, 1:26 PM

No, my only motivation was reading the interface and doing a double-take. I thought maybe the int return type was meant to not only signify whether the pointer was to the given type, but also the index at which that type existed in the union. I had to read the body of the function to learn that this wasn't the case. A bool return type, at least in my case, would have prevented that initial confusion.

This revision was automatically updated to reflect the committed changes.