[clang] 78fb8b0 - [analyzer][NFC] Remove dead LiveVariables::Observer::observerKill (#157661)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 9 06:37:40 PDT 2025
Author: Balazs Benics
Date: 2025-09-09T15:37:36+02:00
New Revision: 78fb8b033695ba327388519754a3288eec11cdb1
URL: https://github.com/llvm/llvm-project/commit/78fb8b033695ba327388519754a3288eec11cdb1
DIFF: https://github.com/llvm/llvm-project/commit/78fb8b033695ba327388519754a3288eec11cdb1.diff
LOG: [analyzer][NFC] Remove dead LiveVariables::Observer::observerKill (#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.
Added:
Modified:
clang/include/clang/Analysis/Analyses/LiveVariables.h
clang/lib/Analysis/LiveVariables.cpp
Removed:
################################################################################
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