[llvm-commits] Trivial warning
Benjamin Kramer
benny.kra at gmail.com
Fri Nov 16 08:00:47 PST 2012
On 16.11.2012, at 13:11, Joe Abbey <jabbey at arxan.com> wrote:
> On Nov 16, 2012, at 12:38 AM, Joe Abbey <jabbey at arxan.com> wrote:
>
>> Hal (et al),
>>
>> One of my build bots reported a warning:
>> PPCRegisterInfo.cpp:501:51: warning: cast from type ‘const llvm::MachineFunction*’ to type ‘llvm::MachineFunction*’ casts away qualifiers [-Wcast-qual]
>> Index: lib/Target/PowerPC/PPCRegisterInfo.cpp
>> ===================================================================
>> --- lib/Target/PowerPC/PPCRegisterInfo.cpp (revision 168110)
>> +++ lib/Target/PowerPC/PPCRegisterInfo.cpp (working copy)
>> @@ -498,7 +498,8 @@
>> } else if (CRSpillFrameIdx) {
>> FrameIdx = CRSpillFrameIdx;
>> } else {
>> - MachineFrameInfo *MFI = ((MachineFunction &)MF).getFrameInfo();
>> + MachineFrameInfo *MFI =
>> + (const_cast<MachineFunction &>MF).getFrameInfo();
>> FrameIdx = MFI->CreateFixedObject((uint64_t)4, (int64_t)-4, true);
>> CRSpillFrameIdx = FrameIdx;
>> }
>>
>> Ok to commit?
>
> Past Joe,
>
> Make sure your current build is setup to do PowerPC builds.
>
> Also, swapping a warning for an error is a horrible trade… let's try that patch again:
>
> Index: lib/Target/PowerPC/PPCRegisterInfo.cpp
> ===================================================================
> --- lib/Target/PowerPC/PPCRegisterInfo.cpp (revision 168110)
> +++ lib/Target/PowerPC/PPCRegisterInfo.cpp (working copy)
> @@ -498,7 +498,8 @@
> } else if (CRSpillFrameIdx) {
> FrameIdx = CRSpillFrameIdx;
> } else {
> - MachineFrameInfo *MFI = ((MachineFunction &)MF).getFrameInfo();
> + MachineFrameInfo *MFI =
> + (const_cast<MachineFunction &>(MF)).getFrameInfo();
> FrameIdx = MFI->CreateFixedObject((uint64_t)4, (int64_t)-4, true);
> CRSpillFrameIdx = FrameIdx;
> }
While this would be the right way to silence the warning, the whole thing looks like a horrible hack to me. Shouldn't the FrameIdx generated in a place where MF isn't const?
- Ben
More information about the llvm-commits
mailing list