[cfe-commits] Patch - Fix range-based for-loop so that it forms proper integer literals

Richard Smith richard at metafoo.co.uk
Mon May 2 15:27:23 PDT 2011


Hi Richard,

On Mon, May 2, 2011 22:22, Richard Trieu wrote:
>> Index: lib/Sema/SemaStmt.cpp
>> ===================================================================
>> --- lib/Sema/SemaStmt.cpp        (revision 129825)
>> +++ lib/Sema/SemaStmt.cpp        (working copy)
>> @@ -1257,7 +1257,8 @@
>> ExprResult BoundExpr;
>> if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(UnqAT))
>> BoundExpr = Owned(IntegerLiteral::Create(Context, CAT->getSize(),
>> -                                                 Context.IntTy,
>> RangeLoc));
>> +
>> Context.getPointerDiffType(),
>> +                                                 RangeLoc));
>>
>> This should be the pointer difference type for the right address space.
>>  You could add an accessor to ASTContext to get the corresponding type
>> for the array's address space from the target info (perhaps
>> ASTContext::getArrayBoundType(QualType ArrayType)).
>
> I am not sure I understand.  I thought that there's only one pointer
> difference type?

In C and C++, there is, but TargetInfo provides the possibility of
different PtrDiffTypes for each address space. However, looking a little
deeper it seems that clang doesn't actually use those other types yet, so
I think your latest patch is fine for now. Feel free to check it in!

Thanks,
Richard





More information about the cfe-commits mailing list