From d82e993cd34ae6fda1eeb57c1b4d3d2629960664 Mon Sep 17 00:00:00 2001 From: Brian Gesiak Date: Sat, 1 Feb 2020 15:03:54 -0500 Subject: [PATCH] [ADT] 'PointerUnion::is' returns 'bool' Summary: 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). Reviewers: gribozavr, gribozavr2, rsmith, bkramer, dblaikie Subscribers: dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73836 --- llvm/include/llvm/ADT/PointerUnion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h index 40b7b000da4..8a5ecfce5a3 100644 --- a/llvm/include/llvm/ADT/PointerUnion.h +++ b/llvm/include/llvm/ADT/PointerUnion.h @@ -181,7 +181,7 @@ public: explicit operator bool() const { return !isNull(); } /// Test if the Union currently holds the type matching T. - template int is() const { + template bool is() const { constexpr int Index = pointer_union_detail::TypeIndex::Index; static_assert(Index < sizeof...(PTs), "PointerUnion::is given type not in the union"); -- 2.11.0