29 return Origins ==
Other.Origins;
33 void dump(llvm::raw_ostream &OS)
const {
34 OS <<
"LoanPropagationLattice State:\n";
35 if (Origins.isEmpty())
37 for (
const auto &Entry : Origins) {
38 if (Entry.second.isEmpty())
39 OS <<
" Origin " << Entry.first <<
" contains no loans\n";
40 for (
const LoanID &LID : Entry.second)
41 OS <<
" Origin " << Entry.first <<
" contains Loan " << LID <<
"\n";
49 AnalysisImpl(
const CFG &
C, AnalysisDeclContext &AC, FactManager &F,
50 OriginLoanMap::Factory &OriginLoanMapFactory,
51 LoanSet::Factory &LoanSetFactory)
52 : DataflowAnalysis(
C, AC, F), OriginLoanMapFactory(OriginLoanMapFactory),
53 LoanSetFactory(LoanSetFactory) {}
57 StringRef getAnalysisName()
const {
return "LoanPropagation"; }
59 Lattice getInitialState() {
return Lattice{}; }
63 Lattice join(Lattice A, Lattice B) {
65 A.Origins, B.Origins, OriginLoanMapFactory,
67 assert((S1 || S2) &&
"unexpectedly merging 2 empty sets");
72 return utils::join(*S1, *S2, LoanSetFactory);
77 return Lattice(JoinedOrigins);
81 Lattice
transfer(Lattice In,
const IssueFact &F) {
83 LoanID LID = F.getLoanID();
84 return Lattice(OriginLoanMapFactory.add(
86 LoanSetFactory.add(LoanSetFactory.getEmptySet(), LID)));
92 Lattice
transfer(Lattice In,
const OriginFlowFact &F) {
93 OriginID DestOID = F.getDestOriginID();
94 OriginID SrcOID = F.getSrcOriginID();
97 F.getKillDest() ? LoanSetFactory.getEmptySet() : getLoans(In, DestOID);
98 LoanSet SrcLoans = getLoans(In, SrcOID);
101 return Lattice(OriginLoanMapFactory.add(
In.Origins, DestOID, MergedLoans));
105 return getLoans(getState(P), OID);
110 if (
auto *Loans = L.Origins.lookup(OID))
112 return LoanSetFactory.getEmptySet();
115 OriginLoanMap::Factory &OriginLoanMapFactory;
116 LoanSet::Factory &LoanSetFactory;
121 using AnalysisImpl::AnalysisImpl;
126 OriginLoanMap::Factory &OriginLoanMapFactory,
127 LoanSet::Factory &LoanSetFactory)
128 : PImpl(
std::make_unique<
Impl>(
C, AC, F, OriginLoanMapFactory,
136 return PImpl->getLoans(OID, P);
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
A generic, policy-based driver for dataflow analyses.
LoanSet getLoans(OriginID OID, ProgramPoint P) const
~LoanPropagationAnalysis()
LoanPropagationAnalysis(const CFG &C, AnalysisDeclContext &AC, FactManager &F, OriginLoanMap::Factory &OriginLoanMapFactory, LoanSet::Factory &LoanSetFactory)
void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env, Environment::ValueModel &Model)
Evaluates S and updates Env accordingly.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
@ Asymmetric
An asymmetric join preserves keys unique to the first map as-is, while applying the JoinValues operat...
static llvm::ImmutableSet< T > join(llvm::ImmutableSet< T > A, llvm::ImmutableSet< T > B, typename llvm::ImmutableSet< T >::Factory &F)
Computes the union of two ImmutableSets.
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
llvm::ImmutableSet< LoanID > LoanSet
utils::ID< struct LoanTag > LoanID
utils::ID< struct OriginTag > OriginID
llvm::ImmutableMap< OriginID, LoanSet > OriginLoanMap
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
bool operator!=(CanQual< T > x, CanQual< U > y)
@ Other
Other implicit parameter.