llvm-project
a1d40dd0 - [clang-tidy] Fix false positives about reinitialization detection in `bugprone-use-after-move` (#197438)

Commit
1 day ago
[clang-tidy] Fix false positives about reinitialization detection in `bugprone-use-after-move` (#197438) When calling base class's `operator=` through derived object, a implicit cast with `UncheckedDerivedToBase` will be generated: ``` void foo() { Base b; Derived d; std::move(d); d = b; } ``` AST for `d = b`'s `d`: ``` |-ImplicitCastExpr <col:3> 'GH62206::Base' lvalue <UncheckedDerivedToBase (Base)> | `-DeclRefExpr <col:3> 'Derived' lvalue Var 0x1d11a400 'd' 'Derived' ``` This patch considers possible `implicitCastExpr` in the reinit matcher, i didn't find other cast situtaions which may causes other problems, so i use `ignoringImpCasts` directly rather than specific to `CK_UncheckedDerivedToBase` here. Closes #62206. --------- Co-authored-by: Zeyi Xu <zeyi2@nekoarch.cc>
Author
Parents
Loading