Skip to content

[SIL] NFC: Fix -Wdeprecated-copy warnings #32405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions include/swift/SIL/OwnershipUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ bool isOwnedForwardingInstruction(SILInstruction *inst);
/// previous terminator.
bool isOwnedForwardingValue(SILValue value);

struct BorrowingOperandKind {
enum Kind {
class BorrowingOperandKind {
public:
enum Kind : uint8_t {
BeginBorrow,
BeginApply,
Branch,
};

private:
Kind value;

public:
BorrowingOperandKind(Kind newValue) : value(newValue) {}
BorrowingOperandKind(const BorrowingOperandKind &other)
: value(other.value) {}

operator Kind() const { return value; }

static Optional<BorrowingOperandKind> get(SILInstructionKind kind) {
Expand Down Expand Up @@ -207,15 +209,20 @@ struct BorrowingOperand {
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
const BorrowingOperand &operand);

struct BorrowedValueKind {
class BorrowedValueKind {
public:
/// Enum we use for exhaustive pattern matching over borrow scope introducers.
enum Kind {
enum Kind : uint8_t {
LoadBorrow,
BeginBorrow,
SILFunctionArgument,
Phi,
};

private:
Kind value;

public:
static Optional<BorrowedValueKind> get(SILValue value) {
if (value.getOwnershipKind() != ValueOwnershipKind::Guaranteed)
return None;
Expand All @@ -240,10 +247,8 @@ struct BorrowedValueKind {
}
}

Kind value;

BorrowedValueKind(Kind newValue) : value(newValue) {}
BorrowedValueKind(const BorrowedValueKind &other) : value(other.value) {}

operator Kind() const { return value; }

/// Is this a borrow scope that begins and ends within the same function and
Expand Down Expand Up @@ -383,18 +388,20 @@ bool getAllBorrowIntroducingValues(SILValue value,
/// introducer, then we return a .some(BorrowScopeIntroducingValue).
Optional<BorrowedValue> getSingleBorrowIntroducingValue(SILValue inputValue);

struct InteriorPointerOperandKind {
class InteriorPointerOperandKind {
public:
enum Kind : uint8_t {
RefElementAddr,
RefTailAddr,
OpenExistentialBox,
};

private:
Kind value;

public:
InteriorPointerOperandKind(Kind newValue) : value(newValue) {}
InteriorPointerOperandKind(const InteriorPointerOperandKind &other)
: value(other.value) {}

operator Kind() const { return value; }

static Optional<InteriorPointerOperandKind> get(Operand *use) {
Expand Down Expand Up @@ -467,8 +474,9 @@ struct InteriorPointerOperand {
: operand(op), kind(kind) {}
};

struct OwnedValueIntroducerKind {
enum Kind {
class OwnedValueIntroducerKind {
public:
enum Kind : uint8_t {
/// An owned value that is a result of an Apply.
Apply,

Expand Down Expand Up @@ -519,6 +527,10 @@ struct OwnedValueIntroducerKind {
AllocRefInit,
};

private:
Kind value;

public:
static Optional<OwnedValueIntroducerKind> get(SILValue value) {
if (value.getOwnershipKind() != ValueOwnershipKind::Owned)
return None;
Expand Down Expand Up @@ -569,11 +581,8 @@ struct OwnedValueIntroducerKind {
llvm_unreachable("Default should have caught this");
}

Kind value;

OwnedValueIntroducerKind(Kind newValue) : value(newValue) {}
OwnedValueIntroducerKind(const OwnedValueIntroducerKind &other)
: value(other.value) {}

operator Kind() const { return value; }

void print(llvm::raw_ostream &os) const;
Expand Down