[cfe-commits] r74404 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/ext_vector_casts.c

Nate Begeman natebegeman at mac.com
Sun Jun 28 11:31:19 PDT 2009


On Jun 27, 2009, at 11:34 PM, Eli Friedman wrote:

> On Sat, Jun 27, 2009 at 9:01 PM, Nate Begeman<natebegeman at mac.com>  
> wrote:
>>
>> On Jun 27, 2009, at 10:13 PM, Eli Friedman wrote:
>>
>>> On Sat, Jun 27, 2009 at 7:36 PM, Nate Begeman<natebegeman at mac.com>  
>>> wrote:
>>>>
>>>> +  // Handle the case of an ext vector and scalar
>>>> +  if (const ExtVectorType *LV = lhsType->getAsExtVectorType()) {
>>>> +    QualType EltTy = LV->getElementType();
>>>> +    if (EltTy->isIntegralType() && rhsType->isIntegralType()) {
>>>> +      if (Context.getIntegerTypeOrder(EltTy, rhsType) >= 0) {
>>>> +        ImpCastExprToType(rex, EltTy);
>>>> +        rex = new (Context) CStyleCastExpr(lhsType, rex, lhsType,
>>>> +
>>>> rex->getSourceRange().getBegin(),
>>>> +
>>>> rex->getSourceRange().getEnd());
>>>> +        if (swapped) std::swap(rex, lex);
>>>> +        return lhsType;
>>>> +      }
>>>> +    }
>>>
>>> Creating a CStyleCastExpr here leads to a misleading AST; is there
>>> some reason why you can't just use ImpCastExprToType(rex, lhsType)"?
>>
>> This avoided significant modifications to CodeGen, and accomplished  
>> the
>> desired effect.
>
> What changes are you talking about?  I just tried it in my tree, and
> it appears to work fine without any additional changes.

I'll try the OpenCL tests again without this change; there were  
problems in the branch of clang we were working with where codegen  
would not perform the correct conversion of the scalar value to  
element type, and then splat to vector type without the two casts in  
the AST.  If this is no longer the case, I'll happily remove it.   
Added to to-do list.

Nate




More information about the cfe-commits mailing list