[PATCH] D116490: [clangd] Code action to declare missing move/copy constructor/assignment
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 10 03:26:47 PST 2022
hokein added inline comments.
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp:72
+//
+// e.g. given `struct S{};`, produces:
+// struct S {
----------------
nit: add trigger points.
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp:120
+ // they should be =default or =delete.
+ Inputs.AST->getSema().ForceDeclarationOfImplicitMembers(Class);
+ std::string Code = buildSpecialMemberDeclarations(*Class);
----------------
I think we need this because these members are created lazily in clang, e.g. if the empty struct `s` is not used, there is no constructor decl being created.
The `ForceDeclarationOfImplicitMembers` is a member function which can mutate the parameter `Class`, I was wondering whether it would lead some bad side-effect, but I didn't come out one (and the mutation is mostly creating a new ctor-decl and adding it to the Class).
================
Comment at: clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp:146
+private:
+ bool NeedCopy, NeedMove;
+ CXXRecordDecl *Class = nullptr;
----------------
nit: add default value
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116490/new/
https://reviews.llvm.org/D116490
More information about the cfe-commits
mailing list