This patch adds missing assignment operator to the class which has user-defined copy/move constructor.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This looks good with one exception; I think the changes for class SemaDiagnosticBuilder are not what was intended.
clang/include/clang/Analysis/BodyFarm.h | ||
---|---|---|
41–46 | This looks fine; move constructor and assignment declarations are inhibited. | |
clang/include/clang/Sema/ParsedAttr.h | ||
704–705 | This class has a move constructor, but the implicit declaration of a move assignment operator will be inhibited due to the presence of this and other special member functions. That means that an attempted move assignment will find the deleted copy assignment. That is ok; if support for move assignment is desired some day, it can be added then. | |
916–918 | This looks fine; move constructor and assignment declarations are inhibited. | |
clang/include/clang/Sema/Sema.h | ||
1786 ↗ | (On Diff #519331) | Since this class declares a move constructor, the declaration of the implicit move assignment operator is inhibited and the implicitly declared assignment operator is defined as deleted. This change declares a move assignment operator but doesn't define it (perhaps = delete was intended?). If support for assignment is not desired, then I think a declaration of a deleted copy assignment operator is all that is needed (matching the change made for Strategy below). Otherwise, I think a defaulted copy assignment operator should be declared and a move assignment operator should be defined that implements the same behavior as the move constructor. |
clang/lib/Analysis/UnsafeBufferUsage.cpp | ||
764–767 | This is ok. The implicit move assignment declaration is inhibited and since copy assignment is deleted, no assignment is supported. If move assignment is desired someday, it can be added. | |
clang/lib/Serialization/ASTWriterStmt.cpp | ||
44–46 | This looks fine; implicit move construction and assignment declarations are inhibited. |
Thanks @tahonermann for reviews. I have addressed review comments and updated patches.
clang/include/clang/Sema/ParsedAttr.h | ||
---|---|---|
704–705 | I have added defaulted move assignment operator which seems needed based on analysis with other bugs. | |
clang/include/clang/Sema/Sema.h | ||
1786 ↗ | (On Diff #519331) | Thanks @tahonermann for the comments.
I have updated patch based on further analysis and my understanding. This seems reasonable to me. |
clang/include/clang/Sema/Sema.h | ||
---|---|---|
1786 ↗ | (On Diff #519331) | This change still declares a move assignment operator, but doesn't provide a definition. The move constructor is implemented in clang/lib/Sema/Sema.cpp, so I would expect to see the move assignment operator definition provided there as well. |
clang/include/clang/Sema/Sema.h | ||
---|---|---|
1786 ↗ | (On Diff #519331) | Thanks @tahonermann for the comments. I have removed Sema.h change from the current patch. I will address it in a separate review pull request. Need to look into this more. |
Compiling with clang 15.0.5 I get the following warning/error with this patch:
../../clang/include/clang/Sema/ParsedAttr.h:705:18: error: explicitly defaulted move assignment operator is implicitly deleted [-Werror,-Wdefaulted-function-deleted] AttributePool &operator=(AttributePool &&pool) = default; ^ ../../clang/include/clang/Sema/ParsedAttr.h:674:21: note: move assignment operator of 'AttributePool' is implicitly deleted because field 'Factory' is of reference type 'clang::AttributeFactory &' AttributeFactory &Factory; ^ 1 error generated.
Thank you @uabelho for reporting. Build error is fixed by https://github.com/llvm/llvm-project/commit/292a6c1c2395f990bbde8d968825243e4fe9b954
This looks fine; move constructor and assignment declarations are inhibited.