This patch adds a new clang-tidy to identify situations where a user is accidentally calling a copy constructor instead of a move constructor as part of a constructor initializer list. The code is likely to silently "work", but with surprising results. Consider:
struct B {
B() {} B(const B&) {} B(B &&) {}
};
struct D : B {
D() : B() {} D(const D &RHS) : B(RHS) {} // Correct D(D &&RHS) : B(RHS) {} // Oops, calls the copy constructor
};
One thing I am not certain of in this patch is how to test it. I have some rudimentary tests, but am unable to test the "note:" diagnostics from FileCheck (attempting to add any cause the "warning:" diagnostics to not be found). I suspect this is why clang-tidy.sh exists, but unfortunately, that means the tests will not be run on Windows (which is the platform I am developing on). Suggestions on how to improve the tests are welcome, but for now, I'm not testing the note diagnostics.
Another problem I'm not certain how to solve is how to phrase the note diagnostics with the constructors are implicitly-defined instead of written. Currently, the notes attach to the record declaration. Would it make sense to have extra text in that case which tells the user the constructors are implicitly defined? Or is there a better way to surface the notes?
Thanks!
~Aaron
clang-format?