[llvm-commits] Patch to update LLVM/Tools with getPointerTo getting multiple address space support

Duncan Sands baldrick at free.fr
Thu Oct 25 07:50:29 PDT 2012


Hi Micah,

>> On Wed, Oct 24, 2012 at 2:43 PM, Villmow, Micah <Micah.Villmow at amd.com>
>> wrote:
>>> Here is a cleaned up version of the patch.
>>
>> +  /// getPointerTo - Return a pointer of the current type.
>> +  PointerType *getPointerTo();
>>
>> I don't see why you're keeping this API around.
> [Villmow, Micah] This is a new API that is used quite often to get a pointer to a type based on the type.
> For example there is I32PtrTy->getPointerTo()->getPointerTo(). Without this API, I would have to write,
> I32PtrTy->getPointerTo(I32PtrTy)->getPointerTo()->(I32PtrTy). The other two API's are only used if you want
> to change the address space of the pointer and not use what is already there.

the problem is that thanks to this method you can accidentally forget the
address space very easily.  If instead you eliminate the method and always
require an address space then at least people will be forced to think about
what the address space should be.  I'm also not convinced by your example,
since you can always write I32PtrTy->getPointerTo(0)->getPointerTo(0).

Ciao, Duncan.



More information about the llvm-commits mailing list