[clang-tidy] Harden PreferMemberInitializerCheck
authorNathan James <n.james93@hotmail.co.uk>
Mon, 22 Feb 2021 19:41:11 +0000 (19:41 +0000)
committerNathan James <n.james93@hotmail.co.uk>
Mon, 22 Feb 2021 19:41:11 +0000 (19:41 +0000)
commita2e15fa532f36db7080347fbae31470c8ceaffc4
tree99a3fd22bc17a7a3e41fc342d79684ea37f3d90d
parent54529c4be64ec5f2269460df52602f0242e54a75
[clang-tidy] Harden PreferMemberInitializerCheck

Prevent warning when the values are initialized using fields that will be initialized later or VarDecls defined in the constructors body.
Both of these cases can't be safely fixed.
Also improve logic of finding where to insert member initializers, previously it could be confused by in class member initializers.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D97132
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp