From 9208e75746c20a002c35598f4d903e9964b03a86 Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Tue, 9 Sep 2025 16:08:09 +0200 Subject: [PATCH] [analyzer][NFC] Modernize LivenessValues::isLive Removing statefullness also adds the benefit of short circuiting. --- clang/lib/Analysis/LiveVariables.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp index 5e07d83c13384..74b930bf26fb6 100644 --- a/clang/lib/Analysis/LiveVariables.cpp +++ b/clang/lib/Analysis/LiveVariables.cpp @@ -72,15 +72,17 @@ bool LiveVariables::LivenessValues::isLive(const Expr *E) const { bool LiveVariables::LivenessValues::isLive(const VarDecl *D) const { if (const auto *DD = dyn_cast(D)) { - bool alive = false; - for (const BindingDecl *BD : DD->bindings()) - alive |= liveBindings.contains(BD); - // Note: the only known case this condition is necessary, is when a bindig // to a tuple-like structure is created. The HoldingVar initializers have a // DeclRefExpr to the DecompositionDecl. - alive |= liveDecls.contains(DD); - return alive; + if (liveDecls.contains(DD)) + return true; + + for (const BindingDecl *BD : DD->bindings()) { + if (liveBindings.contains(BD)) + return true; + } + return false; } return liveDecls.contains(D); }