[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init

Malcolm Parsons via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 4 07:33:47 PST 2017


malcolm.parsons added inline comments.


================
Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:161
             cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-            declRefExpr());
+            declRefExpr(unless(to(varDecl()))));
 
----------------
aaron.ballman wrote:
> Any `varDecl`? Or do we want to limit it to only `parmVarDecl` instead?
> ```
> int i = 12;
> struct S {
>   int j;
>   S() : j(i) {}
> };
> ```
> It seems reasonable to suggest the member initialization be "fixed" to: `int j = i;`
I would find a default member initializer that is not a constant to be surprising.
Maybe I want to limit it to `enumConstantDecl`.


https://reviews.llvm.org/D28287





More information about the cfe-commits mailing list