[llvm-branch-commits] [lld] [NFC][ELF] Remove Symbol's unused copy constructor (PR #210615)
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Aug 2 12:58:40 PDT 2026
================
@@ -78,9 +78,17 @@ class Symbol {
// The file from which this symbol was created.
InputFile *file;
- // The default copy constructor is deleted due to atomic flags. Define one for
- // places where no atomic is needed.
- Symbol(const Symbol &o) { memcpy(static_cast<void *>(this), &o, sizeof(o)); }
+ // Although the copy/move constructors/assignment operators are deleted due
----------------
MaskRay wrote:
We can delete copy ctor/copy assignment operator (prevailing in llvm), which suppress move ctor/assignment.
And trim the comment
```
+ // Symbols are referenced by pointer throughout the linker, so an implicit
+ // copy would create a dangerous duplicate; copy the needed members
+ // explicitly instead. Deleting the copy operations also suppresses the
+ // implicit move operations.
+ Symbol(const Symbol &) = delete;
+ Symbol &operator=(const Symbol &) = delete;
```
https://github.com/llvm/llvm-project/pull/210615
More information about the llvm-branch-commits
mailing list