-Wdeprecated-clean: Fix cases of violating the rule of 5 in ways that are deprecated in C++11

Various targets use std::swap on specific MCAsmOperands (ARM and
possibly Hexagon as well). It might be helpful to mark those subclasses
as final, to ensure that the availability of move/copy operations can't
lead to slicing. (same sort of requirements as the non-vitual dtor -
protected or a final class)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243820 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2015-08-01 04:40:41 +00:00
parent 0dd9ec77d1
commit 299ab3d150
2 changed files with 10 additions and 83 deletions

View File

@ -30,9 +30,17 @@ class MCParsedAsmOperand {
/// MS-style inline assembly.
std::string Constraint;
protected:
// This only seems to need to be movable (by ARMOperand) but ARMOperand has
// lots of members and MSVC doesn't support defaulted move ops, so to avoid
// that verbosity, just rely on defaulted copy ops. It's only the Constraint
// string member that would benefit from movement anyway.
MCParsedAsmOperand(const MCParsedAsmOperand &RHS) = default;
MCParsedAsmOperand &operator=(const MCParsedAsmOperand&) = default;
MCParsedAsmOperand() = default;
public:
MCParsedAsmOperand() {}
virtual ~MCParsedAsmOperand() {}
virtual ~MCParsedAsmOperand() = default;
void setConstraint(StringRef C) { Constraint = C.str(); }
StringRef getConstraint() { return Constraint; }

View File

@ -563,87 +563,6 @@ class ARMOperand : public MCParsedAsmOperand {
public:
ARMOperand(KindTy K) : MCParsedAsmOperand(), Kind(K) {}
ARMOperand(const ARMOperand &o) : MCParsedAsmOperand() {
Kind = o.Kind;
StartLoc = o.StartLoc;
EndLoc = o.EndLoc;
switch (Kind) {
case k_CondCode:
CC = o.CC;
break;
case k_ITCondMask:
ITMask = o.ITMask;
break;
case k_Token:
Tok = o.Tok;
break;
case k_CCOut:
case k_Register:
Reg = o.Reg;
break;
case k_RegisterList:
case k_DPRRegisterList:
case k_SPRRegisterList:
Registers = o.Registers;
break;
case k_VectorList:
case k_VectorListAllLanes:
case k_VectorListIndexed:
VectorList = o.VectorList;
break;
case k_CoprocNum:
case k_CoprocReg:
Cop = o.Cop;
break;
case k_CoprocOption:
CoprocOption = o.CoprocOption;
break;
case k_Immediate:
Imm = o.Imm;
break;
case k_MemBarrierOpt:
MBOpt = o.MBOpt;
break;
case k_InstSyncBarrierOpt:
ISBOpt = o.ISBOpt;
case k_Memory:
Memory = o.Memory;
break;
case k_PostIndexRegister:
PostIdxReg = o.PostIdxReg;
break;
case k_MSRMask:
MMask = o.MMask;
break;
case k_BankedReg:
BankedReg = o.BankedReg;
break;
case k_ProcIFlags:
IFlags = o.IFlags;
break;
case k_ShifterImmediate:
ShifterImm = o.ShifterImm;
break;
case k_ShiftedRegister:
RegShiftedReg = o.RegShiftedReg;
break;
case k_ShiftedImmediate:
RegShiftedImm = o.RegShiftedImm;
break;
case k_RotateImmediate:
RotImm = o.RotImm;
break;
case k_ModifiedImmediate:
ModImm = o.ModImm;
break;
case k_BitfieldDescriptor:
Bitfield = o.Bitfield;
break;
case k_VectorIndex:
VectorIndex = o.VectorIndex;
break;
}
}
/// getStartLoc - Get the location of the first token of this operand.
SMLoc getStartLoc() const override { return StartLoc; }