Skip to content

Commit 2fb29f8

Browse files
authored
[analyzer][NFC] Modernize LivenessValues::isLive (#157800)
Removing statefullness also adds the benefit of short circuiting.
1 parent 0b696a8 commit 2fb29f8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

clang/lib/Analysis/LiveVariables.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,17 @@ bool LiveVariables::LivenessValues::isLive(const Expr *E) const {
7272

7373
bool LiveVariables::LivenessValues::isLive(const VarDecl *D) const {
7474
if (const auto *DD = dyn_cast<DecompositionDecl>(D)) {
75-
bool alive = false;
76-
for (const BindingDecl *BD : DD->bindings())
77-
alive |= liveBindings.contains(BD);
78-
7975
// Note: the only known case this condition is necessary, is when a bindig
8076
// to a tuple-like structure is created. The HoldingVar initializers have a
8177
// DeclRefExpr to the DecompositionDecl.
82-
alive |= liveDecls.contains(DD);
83-
return alive;
78+
if (liveDecls.contains(DD))
79+
return true;
80+
81+
for (const BindingDecl *BD : DD->bindings()) {
82+
if (liveBindings.contains(BD))
83+
return true;
84+
}
85+
return false;
8486
}
8587
return liveDecls.contains(D);
8688
}

0 commit comments

Comments
 (0)