[llvm] r221454 - Fixing some -Wcast-qual warnings; NFC.

Eli Bendersky eliben at google.com
Thu Nov 6 08:40:01 PST 2014


On Thu, Nov 6, 2014 at 8:26 AM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Thu, Nov 6, 2014 at 6:32 AM, Aaron Ballman <aaron at aaronballman.com>
> wrote:
>
>> Author: aaronballman
>> Date: Thu Nov  6 08:32:30 2014
>> New Revision: 221454
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=221454&view=rev
>> Log:
>> Fixing some -Wcast-qual warnings; NFC.
>>
>> Modified:
>>     llvm/trunk/lib/Target/NVPTX/NVPTXLowerStructArgs.cpp
>>
>> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXLowerStructArgs.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXLowerStructArgs.cpp?rev=221454&r1=221453&r2=221454&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/NVPTX/NVPTXLowerStructArgs.cpp (original)
>> +++ llvm/trunk/lib/Target/NVPTX/NVPTXLowerStructArgs.cpp Thu Nov  6
>> 08:32:30 2014
>> @@ -64,7 +64,7 @@ void NVPTXLowerStructArgs::handleParam(A
>>    const Type *StructType = PType->getElementType();
>>
>>    AllocaInst *AllocA =
>> -    new AllocaInst((Type *)StructType, Arg->getName(), FirstInst);
>> +    new AllocaInst(const_cast<Type *>(StructType), Arg->getName(),
>> FirstInst);
>>
>
> Why is StructType a const Type* anyway? Types are immutable and we (I)
> removed const from all references to them years ago...
>
>


I'm doing a cleanup on this file right now, and will take a look at this
cast as well.

Eli


>
>>    /* Set the alignment to alignment of the byval parameter. This is
>> because,
>>     * later load/stores assume that alignment, and we are going to replace
>> @@ -79,9 +79,9 @@ void NVPTXLowerStructArgs::handleParam(A
>>      Type::getInt8PtrTy(Func->getParent()->getContext(),
>> ADDRESS_SPACE_PARAM),
>>      Type::getInt8PtrTy(Func->getParent()->getContext(),
>> ADDRESS_SPACE_GENERIC)
>>    };
>> -  Function *CvtFunc = (Function *)Intrinsic::getDeclaration(
>> +  Function *CvtFunc = Intrinsic::getDeclaration(
>>        Func->getParent(), Intrinsic::nvvm_ptr_gen_to_param,
>> -      ArrayRef<Type *>((Type **)CvtTypes, 2));
>> +      ArrayRef<Type *>(const_cast<Type **>(CvtTypes), 2));
>>    std::vector<Value *> BC1;
>>    BC1.push_back(
>>        new BitCastInst(Arg,
>> Type::getInt8PtrTy(Func->getParent()->getContext(),
>> @@ -90,9 +90,10 @@ void NVPTXLowerStructArgs::handleParam(A
>>    CallInst *CallCVT = CallInst::Create(CvtFunc, ArrayRef<Value *>(BC1),
>>                                         "cvt_to_param", FirstInst);
>>
>> -  BitCastInst *BitCast = new BitCastInst(
>> -      CallCVT, PointerType::get((Type *)StructType, ADDRESS_SPACE_PARAM),
>> -      Arg->getName(), FirstInst);
>> +  BitCastInst *BitCast =
>> +      new BitCastInst(CallCVT, PointerType::get(const_cast<Type
>> *>(StructType),
>> +                                                ADDRESS_SPACE_PARAM),
>> +                      Arg->getName(), FirstInst);
>>    LoadInst *LI = new LoadInst(BitCast, Arg->getName(), FirstInst);
>>    new StoreInst(LI, AllocA, FirstInst);
>>  }
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141106/0cdec74f/attachment.html>


More information about the llvm-commits mailing list