Skip to content

Commit 78fb8b0

Browse files
authored
[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.
1 parent 090a81f commit 78fb8b0

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

clang/include/clang/Analysis/Analyses/LiveVariables.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,8 @@ class LiveVariables : public ManagedAnalysis {
5858

5959
/// A callback invoked right before invoking the
6060
/// liveness transfer function on the given statement.
61-
virtual void observeStmt(const Stmt *S,
62-
const CFGBlock *currentBlock,
63-
const LivenessValues& V) {}
64-
65-
/// Called when the live variables analysis registers
66-
/// that a variable is killed.
67-
virtual void observerKill(const DeclRefExpr *DR) {}
61+
virtual void observeStmt(const Stmt *S, const CFGBlock *currentBlock,
62+
const LivenessValues &V) {}
6863
};
6964

7065
~LiveVariables() override;

clang/lib/Analysis/LiveVariables.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class TransferFunctions : public StmtVisitor<TransferFunctions> {
175175
void VisitDeclStmt(DeclStmt *DS);
176176
void VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS);
177177
void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *UE);
178-
void VisitUnaryOperator(UnaryOperator *UO);
179178
void Visit(Stmt *S);
180179
};
181180
} // namespace
@@ -397,11 +396,7 @@ void TransferFunctions::VisitBinaryOperator(BinaryOperator *B) {
397396
Killed = writeShouldKill(VD);
398397
if (Killed)
399398
val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD);
400-
401399
}
402-
403-
if (Killed && observer)
404-
observer->observerKill(DR);
405400
}
406401
}
407402
}
@@ -466,8 +461,6 @@ void TransferFunctions::VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS) {
466461

467462
if (VD) {
468463
val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD);
469-
if (observer && DR)
470-
observer->observerKill(DR);
471464
}
472465
}
473466

@@ -487,32 +480,6 @@ VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *UE)
487480
}
488481
}
489482

490-
void TransferFunctions::VisitUnaryOperator(UnaryOperator *UO) {
491-
// Treat ++/-- as a kill.
492-
// Note we don't actually have to do anything if we don't have an observer,
493-
// since a ++/-- acts as both a kill and a "use".
494-
if (!observer)
495-
return;
496-
497-
switch (UO->getOpcode()) {
498-
default:
499-
return;
500-
case UO_PostInc:
501-
case UO_PostDec:
502-
case UO_PreInc:
503-
case UO_PreDec:
504-
break;
505-
}
506-
507-
if (auto *DR = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens())) {
508-
const Decl *D = DR->getDecl();
509-
if (isa<VarDecl>(D) || isa<BindingDecl>(D)) {
510-
// Treat ++/-- as a kill.
511-
observer->observerKill(DR);
512-
}
513-
}
514-
}
515-
516483
LiveVariables::LivenessValues
517484
LiveVariablesImpl::runOnBlock(const CFGBlock *block,
518485
LiveVariables::LivenessValues val,

0 commit comments

Comments
 (0)