[clang-tools-extra] [clang-tidy] Improve `bugprone-infinite-loop` check by adding handing for structured bindings (PR #144213)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 14 03:43:58 PDT 2025
================
@@ -83,6 +83,23 @@ static bool isVarThatIsPossiblyChanged(const Decl *Func, const Stmt *LoopStmt,
isChanged(LoopStmt, Var, Context);
// FIXME: Track references.
}
+
+ if (const auto *BD = dyn_cast<BindingDecl>(DRE->getDecl())) {
+ if (const auto *DD =
+ dyn_cast_if_present<DecompositionDecl>(BD->getDecomposedDecl())) {
----------------
flovent wrote:
But does `BindingDecl::getDecomposedDecl` always return non null value? I find the use of this API in clang, `ValueDecl::getPotentiallyDecomposedVarDecl` does check it nullability,
```
VarDecl *ValueDecl::getPotentiallyDecomposedVarDecl() {
// ...
if (auto *BD = llvm::dyn_cast<BindingDecl>(this))
return llvm::dyn_cast_if_present<VarDecl>(BD->getDecomposedDecl());
return nullptr;
}
```
https://github.com/llvm/llvm-project/pull/144213
More information about the cfe-commits
mailing list