[clang] [analyzer][NFC] Remove dead LiveVariables::Observer::observerKill (PR #157661)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 9 05:43:48 PDT 2025
https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/157661
This API was never used in the clang code base.
There might be downstream users, but I highly doubt that. I think the best is to get rid of this unused API.
>From 47ed659d09acefdcc4c712294f9d0fb925330ead Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Tue, 9 Sep 2025 12:55:42 +0200
Subject: [PATCH] [analyzer][NFC] Remove dead
LiveVariables::Observer::observerKill
This API was never used in the clang code base.
There might be downstream users, but I highly doubt that.
I think the best is to get rid of this unused API.
---
.../clang/Analysis/Analyses/LiveVariables.h | 9 ++---
clang/lib/Analysis/LiveVariables.cpp | 33 -------------------
2 files changed, 2 insertions(+), 40 deletions(-)
diff --git a/clang/include/clang/Analysis/Analyses/LiveVariables.h b/clang/include/clang/Analysis/Analyses/LiveVariables.h
index 480a63cbb8b32..90a0f0f7dc86d 100644
--- a/clang/include/clang/Analysis/Analyses/LiveVariables.h
+++ b/clang/include/clang/Analysis/Analyses/LiveVariables.h
@@ -58,13 +58,8 @@ class LiveVariables : public ManagedAnalysis {
/// A callback invoked right before invoking the
/// liveness transfer function on the given statement.
- virtual void observeStmt(const Stmt *S,
- const CFGBlock *currentBlock,
- const LivenessValues& V) {}
-
- /// Called when the live variables analysis registers
- /// that a variable is killed.
- virtual void observerKill(const DeclRefExpr *DR) {}
+ virtual void observeStmt(const Stmt *S, const CFGBlock *currentBlock,
+ const LivenessValues &V) {}
};
~LiveVariables() override;
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp
index dee7fb275c8f3..891e766407722 100644
--- a/clang/lib/Analysis/LiveVariables.cpp
+++ b/clang/lib/Analysis/LiveVariables.cpp
@@ -175,7 +175,6 @@ class TransferFunctions : public StmtVisitor<TransferFunctions> {
void VisitDeclStmt(DeclStmt *DS);
void VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS);
void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *UE);
- void VisitUnaryOperator(UnaryOperator *UO);
void Visit(Stmt *S);
};
} // namespace
@@ -397,11 +396,7 @@ void TransferFunctions::VisitBinaryOperator(BinaryOperator *B) {
Killed = writeShouldKill(VD);
if (Killed)
val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD);
-
}
-
- if (Killed && observer)
- observer->observerKill(DR);
}
}
}
@@ -466,8 +461,6 @@ void TransferFunctions::VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS) {
if (VD) {
val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD);
- if (observer && DR)
- observer->observerKill(DR);
}
}
@@ -487,32 +480,6 @@ VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *UE)
}
}
-void TransferFunctions::VisitUnaryOperator(UnaryOperator *UO) {
- // Treat ++/-- as a kill.
- // Note we don't actually have to do anything if we don't have an observer,
- // since a ++/-- acts as both a kill and a "use".
- if (!observer)
- return;
-
- switch (UO->getOpcode()) {
- default:
- return;
- case UO_PostInc:
- case UO_PostDec:
- case UO_PreInc:
- case UO_PreDec:
- break;
- }
-
- if (auto *DR = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens())) {
- const Decl *D = DR->getDecl();
- if (isa<VarDecl>(D) || isa<BindingDecl>(D)) {
- // Treat ++/-- as a kill.
- observer->observerKill(DR);
- }
- }
-}
-
LiveVariables::LivenessValues
LiveVariablesImpl::runOnBlock(const CFGBlock *block,
LiveVariables::LivenessValues val,
More information about the cfe-commits
mailing list