[clang-tools-extra] [clang-tidy] Improve bugprone.use-after-move interaction with explicit destructor call. (PR #188866)
Zeyi Xu via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 27 04:09:27 PDT 2026
================
@@ -401,9 +401,12 @@ void UseAfterMoveFinder::getDeclRefs(
}
};
- auto DeclRefMatcher = declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
- unless(inDecltypeOrTemplateArg()))
- .bind("declref");
+ auto DeclRefMatcher =
+ declRefExpr(
+ hasDeclaration(equalsNode(MovedVariable)),
+ unless(inDecltypeOrTemplateArg()),
+ unless(hasParent(memberExpr(hasDeclaration(cxxDestructorDecl())))))
----------------
zeyi2 wrote:
Currently it will fail to ignore cases like:
```cpp
#include <utility>
struct T {
~T() {}
};
void test_intended_change() {
T a;
T a2 = std::move(a);
(a).~T();
}
```
Maybe `ignoringParenImpCasts`?
https://github.com/llvm/llvm-project/pull/188866
More information about the cfe-commits
mailing list