clang: lib/Analysis/LifetimeSafety/Facts.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
12
14
17 OS << "Fact (Kind: " << static_cast<int>(K) << ")\n";
18}
19
22 OS << "Issue (";
24 OS << ", ToOrigin: ";
26 OS << ")\n";
27}
28
31 OS << "Expire (";
33 OS << ")\n";
34}
35
38 OS << "OriginFlow (Dest: ";
40 OS << ", Src: ";
43 OS << ")\n";
44}
45
48 OS << "OriginEscapes (";
50 OS << ")\n";
51}
52
55 OS << "Use (";
57 OS << ", " << (isWritten() ? "Write" : "Read") << ")\n";
58}
59
62 OS << "TestPoint (Annotation: \"" << getAnnotation() << "\")\n";
63}
64
66 llvm::StringMap AnnotationToPointMap;
67 for (const auto &BlockFacts : BlockToFacts) {
68 for (const Fact *F : BlockFacts) {
69 if (const auto *TPF = F->getAs<TestPointFact>()) {
70 StringRef PointName = TPF->getAnnotation();
71 assert(!AnnotationToPointMap.contains(PointName) &&
72 "more than one test points with the same name");
73 AnnotationToPointMap[PointName] = F;
74 }
75 }
76 }
77 return AnnotationToPointMap;
78}
79
81 llvm::dbgs() << "==========================================\n";
82 llvm::dbgs() << " Lifetime Analysis Facts:\n";
83 llvm::dbgs() << "==========================================\n";
85 if (const auto *ND = dyn_cast(D))
86 llvm::dbgs() << "Function: " << ND->getQualifiedNameAsString() << "\n";
87
89 llvm::dbgs() << " Block B" << B->getBlockID() << ":\n";
91 llvm::dbgs() << " ";
92 F->dump(llvm::dbgs(), LoanMgr, OriginMgr);
93 }
94 llvm::dbgs() << " End of Block\n";
95 }
96}
97
100 for (const auto &BlockToFactsVec : BlockToFacts) {
101 for (const Fact *F : BlockToFactsVec)
102 if (F == P)
103 return BlockToFactsVec;
104 }
105 return {};
106}
107
108}
AnalysisDeclContext contains the context data for the function, method or block under analysis.
const Decl * getDecl() const
Represents a single basic block in a source-level CFG.
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Decl - This represents one declaration (or definition), e.g.
void dump(llvm::raw_ostream &OS, const LoanManager &LM, const OriginManager &) const override
Definition Facts.cpp:29
llvm::ArrayRef< const Fact * > getFacts(const CFGBlock *B) const
llvm::StringMap< ProgramPoint > getTestPoints() const
Retrieves program points that were specially marked in the source code for testing.
Definition Facts.cpp:65
void dump(const CFG &Cfg, AnalysisDeclContext &AC) const
Definition Facts.cpp:80
llvm::ArrayRef< const Fact * > getBlockContaining(ProgramPoint P) const
Retrieves all the facts in the block containing Program Point P.
Definition Facts.cpp:99
An abstract base class for a single, atomic lifetime-relevant event.
virtual void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &) const
Definition Facts.cpp:15
void dump(llvm::raw_ostream &OS, const LoanManager &LM, const OriginManager &OM) const override
Definition Facts.cpp:20
OriginID getOriginID() const
Manages the creation, storage and retrieval of loans.
const Loan * getLoan(LoanID ID) const
virtual void dump(llvm::raw_ostream &OS) const =0
OriginID getEscapedOriginID() const
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM) const override
Definition Facts.cpp:46
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM) const override
Definition Facts.cpp:36
OriginID getSrcOriginID() const
OriginID getDestOriginID() const
Manages the creation, storage, and retrieval of origins for pointer-like variables and expressions.
void dump(OriginID OID, llvm::raw_ostream &OS) const
A dummy-fact used to mark a specific point in the code for testing.
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &) const override
Definition Facts.cpp:60
StringRef getAnnotation() const
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM) const override
Definition Facts.cpp:53
OriginID getUsedOrigin() const
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.