[PATCH] D116514: [clangd] Add code action to generate a constructor for a C++ class

Adrian Vogelsgesang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 18 09:33:59 PST 2022

avogelsgesang added inline comments.

Comment at: clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp:49
+      Class = N->ASTNode.get<CXXRecordDecl>();
+    if (!Class || !Class->isThisDeclarationADefinition() || Class->isUnion())
+      return false;
njames93 wrote:
> avogelsgesang wrote:
> > do we also need to exclude anonymous class declarations here? (Not sure if those are also modelled as `CXXRecordDecl` in the clang AST...)
> Good point, should also ensure there is a test case for this as well.
On 2nd thought: To trigger this tweak, I click on the class name, and since anonymous structs don't have class names, I think the tweak can't even be triggered.

Still probably worth a check here, just to be sure. Or at least an `assert`+ comment in the code

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list