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

Brian Gesiak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 1 12:40:59 PST 2020


modocache created this revision.
modocache added reviewers: gribozavr, gribozavr2, rsmith, bkramer, dblaikie.
Herald added a subscriber: dexonsmith.
Herald added a project: LLVM.

The return type of 'PointerUnion::is' has been 'int' since it was first
added in March 2009, in SVN r67987, or
https://github.com/llvm/llvm-project/commit/a9c6de15fb3.

The only other change to this member function was a clang-format applied
in December 2015, in SVN r256513, or
https://github.com/llvm/llvm-project/commit/548a49aacc0.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73836

Files:
  llvm/include/llvm/ADT/PointerUnion.h


Index: llvm/include/llvm/ADT/PointerUnion.h
===================================================================
--- llvm/include/llvm/ADT/PointerUnion.h
+++ llvm/include/llvm/ADT/PointerUnion.h
@@ -181,7 +181,7 @@
   explicit operator bool() const { return !isNull(); }
 
   /// Test if the Union currently holds the type matching T.
-  template <typename T> int is() const {
+  template <typename T> bool is() const {
     constexpr int Index = pointer_union_detail::TypeIndex<T, PTs...>::Index;
     static_assert(Index < sizeof...(PTs),
                   "PointerUnion::is<T> given type not in the union");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73836.241894.patch
Type: text/x-patch
Size: 611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200201/8d262de9/attachment.bin>


More information about the llvm-commits mailing list