[llvm-commits] [llvm] r95557 - /llvm/trunk/include/llvm/Type.h

Chris Lattner clattner at apple.com
Mon Feb 8 21:03:54 PST 2010


On Feb 8, 2010, at 8:38 PM, Duncan Sands wrote:

> Hi Chris,
> 
>>>> Why not just use isa<PointerType>?
>>>> This encourages code to diverge in style.
>>> 
>>> since there already is isFloat, isInteger and variations, it seems odd not
>>> to have these too.  Of course, I could just delete all the guys with an "isa"
>>> version.  What do you think?
>> isInteger is required because we need an argument.
> 
> actually there are two versions of isInteger, one which takes a bitwidth
> argument, and one which just checks the ID.
> 
> I don't really care
>> one way or another though, so long as the code is consistent.  Are you willing to change all isa<PointerType>(x) to X->isPointer() ?
> 
> I was actually suggesting getting rid of all the
> 
>  bool isInteger() const { return ID == IntegerTyID; }
> 
> style methods, and changing them to isa<IntegerType> etc (I guess I didn't
> phrase this clearly).

Ah, ok!  Sure, I'd be fine with that.

> However, I might be persuaded to do it the other way
> round :)  An argument is favour of ...->isInteger() is that it is about 30%
> shorter than isa<IntegerType>(...).  On the other hand, "isa" is consistent
> with all the other classes, isa<BitCastInst> etc.  Personally I'm not fussed
> by having both styles, but if you feel strongly about it I am prepared to do
> some work to improve the situation.

Terseness is nice, but I think the most compelling thing about Foo->isInteger() is that it reads better IMO.

-Chris



More information about the llvm-commits mailing list