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 { 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(UO->getSubExpr()->IgnoreParens())) { - const Decl *D = DR->getDecl(); - if (isa(D) || isa(D)) { - // Treat ++/-- as a kill. - observer->observerKill(DR); - } - } -} - LiveVariables::LivenessValues LiveVariablesImpl::runOnBlock(const CFGBlock *block, LiveVariables::LivenessValues val,