[cfe-commits] [PATCH, RFC] Fix PR14881 (complex integer promotion rules)

Bill Schmidt wschmidt at linux.vnet.ibm.com
Mon Jan 28 10:11:17 PST 2013


On Mon, 2013-01-28 at 08:58 -0600, Bill Schmidt wrote:
> >Something along these lines, but I'd really prefer if you could somehow
> >re-use the logic from handleIntegerConversion.  I think you could if you
> >just made that function take function pointers to do the casts on the left
> >and right parameters:
> >
> >  typedef ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType);
> >  static QualType handleIntegerConversion(Sema &S, ExprResult &LHS,
> >                                        ExprResult &RHS, QualType LHSType,
> >                                        QualType RHSType, bool IsCompAssign,
> >                                        PerformCastFn *doLHSCast, PerformCastFn *doRHSCast)
> >
> >The current use would just use a function like this:
> >  ExprResult doIntegralCast(Sema &S, Expr *op, QualType toType) {
> >    return S.ImpCastExprToType(op, toType, CK_IntegralCast);
> >  }
> >
> >But whenever an operand is complex, you'd instead use:
> >  ExprResult doComplexIntegralCast(Sema &S, Expr *op, QualType toType) {
> >    return S.ImpCastExprToType(op, S.Context.getComplexType(toType), CK_ComplexIntegralCast);
> >  }
> >
> >John.
> 
> Hm, ok, if you prefer.  My intent was to avoid any slowdown to the
> common case of scalar integer conversion.  Complex integer is a GNU
> extension used by -- well, practically nobody.  We need to support it
> for completeness, but its use will be rare.  Using indirect calls incurs
> some performance penalty, so I chose to leave the existing code alone.
> But if you like, I'll cobble this up and see what it looks like.
> 
> (Sorry for losing the conversation threadedness; my mail server was down
> over the weekend and I lost some messages, yours included...)
> 
> Bill

Here's the revised patch that directly reuses handleIntegerConversion().
Is this ok to commit?

Thanks,
Bill
-------------- next part --------------
A non-text attachment was scrubbed...
Name: complex-convert-2013-01-28.patch
Type: text/x-patch
Size: 67442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130128/f6b5f7d0/attachment.bin>


More information about the cfe-commits mailing list