baloghadamsoftware marked 4 inline comments as done.
baloghadamsoftware added inline comments.


================
Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-assignment.cpp:29
+public:
+  Simple2() : n (0) {
+    x = 0.0;
----------------
aaron.ballman wrote:
> By my reading of the core guideline 
> (https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers),
>  it looks like `n` should also be diagnosed because all of the constructors 
> in the class initialize the member to the same constant value. Is there a 
> reason to deviate from the rule (or have I missed something)?
> 
> Also, I'd like to see a test case like:
> ```
> class C {
>   int n;
> public:
>   C() { n = 0; }
>   explicit C(int) { n = 12; }
> };
> ```
This check only cares for initializations inside the body (rule `C.49`, but if 
the proper fix is to convert them to default member initializer according to 
rule `C.48` then we follow that rule in the fix). For initializations 
implemented as constructor member initializers but according to `C.48` they 
should have been implemented as default member initializers we already have 
check `modernize-use-default-member-init`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71199/new/

https://reviews.llvm.org/D71199



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to