Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions clang/include/clang/Analysis/Analyses/LiveVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
33 changes: 0 additions & 33 deletions clang/lib/Analysis/LiveVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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,
Expand Down