[PATCH] D125994: [NFC] Define move and copy constructors and copy assignment operators for MDOperand.
Wolfgang Pieb via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 11:25:31 PDT 2022
wolfgangp created this revision.
wolfgangp added a reviewer: dexonsmith.
Herald added a project: All.
wolfgangp requested review of this revision.
Herald added a project: LLVM.
Preparation for a patch to introduce a resizing functionality for MDNodes. See D124548 <https://reviews.llvm.org/D124548> for a more detailed discussion.
Using a SmallVector<MDOperand> as a large storage container seems to require these constructors/operators to be defined.
https://reviews.llvm.org/D125994
Files:
llvm/include/llvm/IR/Metadata.h
Index: llvm/include/llvm/IR/Metadata.h
===================================================================
--- llvm/include/llvm/IR/Metadata.h
+++ llvm/include/llvm/IR/Metadata.h
@@ -775,10 +775,22 @@
public:
MDOperand() = default;
- MDOperand(MDOperand &&) = delete;
- MDOperand(const MDOperand &) = delete;
- MDOperand &operator=(MDOperand &&) = delete;
- MDOperand &operator=(const MDOperand &) = delete;
+ MDOperand(const MDOperand &&Op) {
+ MD = Op.MD;
+ track(nullptr);
+ }
+ MDOperand(const MDOperand &Op) {
+ MD = Op.MD;
+ track(nullptr);
+ }
+ MDOperand &operator=(const MDOperand &&Op) {
+ reset(Op.MD, nullptr);
+ return *this;
+ }
+ MDOperand &operator=(const MDOperand &Op) {
+ reset(Op.MD, nullptr);
+ return *this;
+ }
~MDOperand() { untrack(); }
Metadata *get() const { return MD; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125994.430740.patch
Type: text/x-patch
Size: 849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220519/2ed3a07d/attachment.bin>
More information about the llvm-commits
mailing list