Skip to content

[Misc] NFC: Fix -Wdefaulted-function-deleted warnings #20649

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
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions include/swift/AST/RawComment.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ struct SingleRawComment {
BlockDoc, ///< \code /** stuff */ \endcode
};

const CharSourceRange Range;
const StringRef RawText;
CharSourceRange Range;
StringRef RawText;

unsigned Kind : 8;
unsigned StartColumn : 16;
Expand Down
4 changes: 3 additions & 1 deletion include/swift/Basic/SourceLoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ class CharSourceRange {

public:
/// \brief Constructs an invalid range.
CharSourceRange() {}
CharSourceRange() = default;

CharSourceRange &operator=(const CharSourceRange &) = default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule of Zero says that we should not declare this explicitly. If you think it's important, we should follow the Rule of Five instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CharSourceRange() {} is effectively CharSourceRange() = default, right? If so, then yes, I can flush out the rule-of-five.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule of Five doesn't include the default constructor anyway, so just deleting this newest line is fine. The reason to keep it would be to see if we regress, I guess, but then we should definitely include all five = default special members.


CharSourceRange(SourceLoc Start, unsigned ByteLength)
: Start(Start), ByteLength(ByteLength) {}
Expand Down
10 changes: 10 additions & 0 deletions include/swift/Basic/TreeScopedHashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ template <typename K, typename V> class TreeScopedHashTableVal {
TreeScopedHashTableVal(const K &Key, const V &Val) : Key(Key), Val(Val) {}

public:
TreeScopedHashTableVal(const TreeScopedHashTableVal &) = delete;
TreeScopedHashTableVal(TreeScopedHashTableVal &&) = delete;
TreeScopedHashTableVal &operator=(const TreeScopedHashTableVal &) = delete;
TreeScopedHashTableVal &operator=(TreeScopedHashTableVal &&) = delete;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule of Five says it's worth mentioning the destructor here too.


const K &getKey() const { return Key; }
const V &getValue() const { return Val; }
V &getValue() { return Val; }
Expand Down Expand Up @@ -144,6 +149,11 @@ class TreeScopedHashTableDetachedScope {
const ImplTy *getImpl() { return DetachedImpl; }

public:
TreeScopedHashTableDetachedScope &operator=(
const TreeScopedHashTableDetachedScope &) = default;
TreeScopedHashTableDetachedScope &operator=(
TreeScopedHashTableDetachedScope &&) = default;

TreeScopedHashTableDetachedScope() : DetachedImpl(0) {}

TreeScopedHashTableDetachedScope(TreeScopedHashTableDetachedScope &&Other)
Expand Down
14 changes: 7 additions & 7 deletions include/swift/SIL/Projection.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,10 +835,10 @@ class ProjectionTreeNode {
class ProjectionTree {
friend class ProjectionTreeNode;

SILModule &Mod;
SILModule *Mod;

/// The allocator we use to allocate ProjectionTreeNodes in the tree.
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator;
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> *Allocator;

// A common pattern is a 3 field struct.
llvm::SmallVector<ProjectionTreeNode *, 4> ProjectionTreeNodes;
Expand All @@ -854,7 +854,7 @@ class ProjectionTree {
/// initialized by initializeWithExistingTree.
ProjectionTree(SILModule &Mod,
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
: Mod(Mod), Allocator(Allocator) {}
: Mod(&Mod), Allocator(&Allocator) {}
~ProjectionTree();
ProjectionTree(const ProjectionTree &) = delete;
ProjectionTree(ProjectionTree &&) = default;
Expand All @@ -876,7 +876,7 @@ class ProjectionTree {
LeafValueMapTy &LeafValues);

/// Return the module associated with this tree.
SILModule &getModule() const { return Mod; }
SILModule &getModule() const { return *Mod; }

llvm::ArrayRef<ProjectionTreeNode *> getProjectionTreeNodes() {
return llvm::makeArrayRef(ProjectionTreeNodes);
Expand Down Expand Up @@ -960,16 +960,16 @@ class ProjectionTree {
void createRoot(SILType BaseTy) {
assert(ProjectionTreeNodes.empty() &&
"Should only create root when ProjectionTreeNodes is empty");
auto *Node = new (Allocator.Allocate()) ProjectionTreeNode(BaseTy);
auto *Node = new (Allocator->Allocate()) ProjectionTreeNode(BaseTy);
ProjectionTreeNodes.push_back(Node);
}

ProjectionTreeNode *createChild(ProjectionTreeNode *Parent,
SILType BaseTy,
const Projection &P) {
unsigned Index = ProjectionTreeNodes.size();
auto *Node = new (Allocator.Allocate()) ProjectionTreeNode(Parent, Index,
BaseTy, P);
auto *Node = new (Allocator->Allocate()) ProjectionTreeNode(Parent, Index,
BaseTy, P);
ProjectionTreeNodes.push_back(Node);
return ProjectionTreeNodes[Index];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/Projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ class NewAggregateBuilderMap {
ProjectionTree::ProjectionTree(
SILModule &Mod, SILType BaseTy,
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
: Mod(Mod), Allocator(Allocator) {
: Mod(&Mod), Allocator(&Allocator) {
LLVM_DEBUG(llvm::dbgs() << "Constructing Projection Tree For : " << BaseTy
<< "\n");

Expand Down
1 change: 0 additions & 1 deletion lib/SILGen/LValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ struct LLVM_LIBRARY_VISIBILITY ExclusiveBorrowFormalAccess : FormalAccess {
ExclusiveBorrowFormalAccess &
operator=(ExclusiveBorrowFormalAccess &&) = default;

ExclusiveBorrowFormalAccess() = default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The superclass doesn't have a default constructor, so the subclass can't either.

ExclusiveBorrowFormalAccess(SILLocation loc,
std::unique_ptr<LogicalPathComponent> &&comp,
ManagedValue base,
Expand Down
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class Callee {
DynamicMethod,
};

const Kind kind;
Kind kind;

// Move, don't copy.
Callee(const Callee &) = delete;
Expand Down
4 changes: 3 additions & 1 deletion lib/SILOptimizer/Transforms/RedundantLoadElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,9 @@ class RLEContext {
EpilogueARCFunctionInfo *EAFI, bool disableArrayLoads);

RLEContext(const RLEContext &) = delete;
RLEContext(RLEContext &&) = default;
RLEContext(RLEContext &&) = delete;
RLEContext &operator=(const RLEContext &) = delete;
RLEContext &operator=(RLEContext &&) = delete;
~RLEContext() = default;

/// Entry point to redundant load elimination.
Expand Down