From 0db235a2b0ed6ae5c3c870012061906054b6dbc4 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 6 Mar 2012 07:14:54 +0000 Subject: PointerUnion::getAddrOf() does not need to be template since we can only use the first pointer type for it. Rename it to getAddrOfPtr1(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152106 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/PointerUnion.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'include/llvm/ADT/PointerUnion.h') diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index 487096a171..036cf60388 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/include/llvm/ADT/PointerUnion.h @@ -142,16 +142,19 @@ namespace llvm { return T(); } - /// \brief If the union is set to the first pointer type we can get an - /// address pointing to it. - template - PT1 const *getAddrOf() const { + /// \brief If the union is set to the first pointer type get an address + /// pointing to it. + PT1 const *getAddrOfPtr1() const { + return const_cast(this)->getAddrOfPtr1(); + } + + /// \brief If the union is set to the first pointer type get an address + /// pointing to it. + PT1 *getAddrOfPtr1() { assert(is() && "Val is not the first pointer"); assert(get() == Val.getPointer() && "Can't get the address because PointerLikeTypeTraits changes the ptr"); - T const *can_only_get_address_of_first_pointer_type - = reinterpret_cast(Val.getAddrOfPointer()); - return can_only_get_address_of_first_pointer_type; + return (PT1 *)Val.getAddrOfPointer(); } /// Assignment operators - Allow assigning into this union from either -- cgit v1.2.3