clang 24.0.0git
Facts.h
Go to the documentation of this file.
1//===- Facts.h - Lifetime Analysis Facts and Fact Manager ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines Facts, which are atomic lifetime-relevant events (such as
10// loan issuance, loan expiration, origin flow, and use), and the FactManager,
11// which manages the storage and retrieval of facts for each CFG block.
12//
13//===----------------------------------------------------------------------===//
14#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_FACTS_H
15#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_FACTS_H
16
17#include "clang/AST/Decl.h"
22#include "clang/Analysis/CFG.h"
23#include "llvm/ADT/BitVector.h"
24#include "llvm/ADT/DenseSet.h"
25#include "llvm/ADT/PointerUnion.h"
26#include "llvm/ADT/STLFunctionalExtras.h"
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/Support/Debug.h"
29#include "llvm/Support/raw_ostream.h"
30#include <cstdint>
31#include <optional>
32
33namespace clang::lifetimes {
34
35/// How an origin is used: by an expression, or implicitly at scope exit by a
36/// destructor or a cleanup callback that may read the borrows it holds.
38
39/// Where and how an origin is used, for diagnostics.
40class UseSite {
41 /// The use expression for an explicit use, or the variable destroyed or
42 /// cleaned up for an implicit one. Null for an explicit use known only by
43 /// its location.
44 llvm::PointerUnion<const Expr *, const VarDecl *> ExprOrVD;
45 /// Used when there is no expression.
48
49 UseSite(llvm::PointerUnion<const Expr *, const VarDecl *> ExprOrVD,
50 SourceLocation Loc, UseKind Kind)
51 : ExprOrVD(ExprOrVD), Loc(Loc), Kind(Kind) {}
52
53public:
54 static UseSite fromExpr(const Expr &E) {
55 return UseSite(&E, SourceLocation(), UseKind::Explicit);
56 }
57 static UseSite at(SourceLocation Loc) {
58 return UseSite(nullptr, Loc, UseKind::Explicit);
59 }
60 static UseSite scopeExit(SourceLocation Loc, const VarDecl &VD,
61 UseKind Kind) {
62 assert((Kind == UseKind::Destructor || Kind == UseKind::Cleanup) &&
63 "scope-exit uses are destructor or cleanup uses");
64 return UseSite(&VD, Loc, Kind);
65 }
66
67 UseKind getKind() const { return Kind; }
68 /// Null for an implicit use or one known only by its location.
69 const Expr *getExpr() const {
70 return dyn_cast_if_present<const Expr *>(ExprOrVD);
71 }
72 /// The variable destroyed or cleaned up, for implicit uses.
73 const VarDecl *getScopeExitVD() const {
74 return dyn_cast_if_present<const VarDecl *>(ExprOrVD);
75 }
77 if (const Expr *E = getExpr())
78 return E->getExprLoc();
79 return Loc;
80 }
81 /// Empty unless there is a use expression.
83 if (const Expr *E = getExpr())
84 return E->getSourceRange();
85 return SourceRange();
86 }
87};
88
89} // namespace clang::lifetimes
90
92
93class FactsGenerator;
94class LoanPropagationAnalysis;
95
97
98/// An abstract base class for a single, atomic lifetime-relevant event.
99class Fact {
100
101public:
102 enum class Kind : uint8_t {
103 /// A new loan is issued from a borrow expression (e.g., &x).
105 /// A loan expires as its underlying storage is freed (e.g., variable goes
106 /// out of scope).
108 /// An origin is propagated from a source to a destination (e.g., p = q).
109 /// This can also optionally kill the destination origin before flowing into
110 /// it. Otherwise, the source's loan set is merged into the destination's
111 /// loan set.
113 /// An origin is used (eg. appears as l-value expression like DeclRefExpr).
115 /// An origin that is moved (e.g., passed to an rvalue reference parameter).
117 /// A marker for a specific point in the code, for testing.
119 /// An origin that escapes the function scope (e.g., via return).
121 /// An origin is invalidated (e.g. vector resized, `delete` called).
123 /// All loans of an origin are cleared.
125 };
126
127private:
128 Kind K;
129 FactID ID;
130
131protected:
132 Fact(Kind K) : K(K) {}
133
134public:
135 virtual ~Fact() = default;
136 Kind getKind() const { return K; }
137
138 void setID(FactID ID) { this->ID = ID; }
139 FactID getID() const { return ID; }
140
141 template <typename T> const T *getAs() const {
142 if (T::classof(this))
143 return static_cast<const T *>(this);
144 return nullptr;
145 }
146
147 virtual void dump(llvm::raw_ostream &OS, const LoanManager &,
148 const OriginManager &,
149 const LoanPropagationAnalysis *LPA = nullptr) const;
150};
151
152/// A `ProgramPoint` identifies a location in the CFG by pointing to a specific
153/// `Fact`. identified by a lifetime-related event (`Fact`).
154///
155/// A `ProgramPoint` has "after" semantics: it represents the location
156/// immediately after its corresponding `Fact`.
157using ProgramPoint = const Fact *;
158
159class IssueFact : public Fact {
160 LoanID LID;
161 OriginID OID;
162
163public:
164 static bool classof(const Fact *F) { return F->getKind() == Kind::Issue; }
165
166 IssueFact(LoanID LID, OriginID OID) : Fact(Kind::Issue), LID(LID), OID(OID) {}
167 LoanID getLoanID() const { return LID; }
168 OriginID getOriginID() const { return OID; }
169 void dump(llvm::raw_ostream &OS, const LoanManager &LM,
170 const OriginManager &OM,
171 const LoanPropagationAnalysis *LPA = nullptr) const override;
172};
173
174/// When an AccessPath expires (e.g., a variable goes out of scope), all loans
175/// that are associated with this path expire. For example, if `x` expires, then
176/// the loan to `x` expires.
177class ExpireFact : public Fact {
178 // The access path that expires.
179 AccessPath AP;
180
181 // Expired origin (e.g., its variable goes out of scope).
182 std::optional<OriginID> OID;
183 SourceLocation ExpiryLoc;
184
185public:
186 static bool classof(const Fact *F) { return F->getKind() == Kind::Expire; }
187
189 std::optional<OriginID> OID = std::nullopt)
190 : Fact(Kind::Expire), AP(AP), OID(OID), ExpiryLoc(ExpiryLoc) {}
191
192 const AccessPath &getAccessPath() const { return AP; }
193 std::optional<OriginID> getOriginID() const { return OID; }
194 SourceLocation getExpiryLoc() const { return ExpiryLoc; }
195
196 void dump(llvm::raw_ostream &OS, const LoanManager &LM,
197 const OriginManager &OM,
198 const LoanPropagationAnalysis *LPA = nullptr) const override;
199};
200
201class OriginFlowFact : public Fact {
202 OriginID OIDDest;
203 OriginID OIDSrc;
204 // True if the destination origin should be killed (i.e., its current loans
205 // cleared) before the source origin's loans are flowed into it.
206 bool KillDest;
207
208public:
209 static bool classof(const Fact *F) {
210 return F->getKind() == Kind::OriginFlow;
211 }
212
213 OriginFlowFact(OriginID OIDDest, OriginID OIDSrc, bool KillDest)
214 : Fact(Kind::OriginFlow), OIDDest(OIDDest), OIDSrc(OIDSrc),
215 KillDest(KillDest) {}
216
217 OriginID getDestOriginID() const { return OIDDest; }
218 OriginID getSrcOriginID() const { return OIDSrc; }
219 bool getKillDest() const { return KillDest; }
220
221 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
222 const LoanPropagationAnalysis *LPA = nullptr) const override;
223};
224
225/// Represents that an origin escapes the current scope through various means.
226/// This is the base class for different escape scenarios.
227class OriginEscapesFact : public Fact {
228 OriginID OID;
229
230public:
231 /// The way an origin can escape the current scope.
232 enum class EscapeKind : uint8_t {
233 Return, /// Escapes via return statement.
234 Field, /// Escapes via assignment to a field.
235 Global, /// Escapes via assignment to global storage.
236 This, /// Escapes via the enclosing object `this`, which outlives the
237 /// method.
239
240 static bool classof(const Fact *F) {
241 return F->getKind() == Kind::OriginEscapes;
242 }
243
246 OriginID getEscapedOriginID() const { return OID; }
247 EscapeKind getEscapeKind() const { return EscKind; }
248};
249
250/// Represents that an origin escapes via a return statement.
252 const Expr *ReturnExpr;
253
254public:
255 ReturnEscapeFact(OriginID OID, const Expr *ReturnExpr)
256 : OriginEscapesFact(OID, EscapeKind::Return), ReturnExpr(ReturnExpr) {}
257
258 static bool classof(const Fact *F) {
259 return F->getKind() == Kind::OriginEscapes &&
260 static_cast<const OriginEscapesFact *>(F)->getEscapeKind() ==
262 }
263 const Expr *getReturnExpr() const { return ReturnExpr; };
264 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
265 const LoanPropagationAnalysis *LPA = nullptr) const override;
266};
267
268/// Represents that an origin escapes via assignment to a field.
269/// Example: `this->view = local_var;` where local_var outlives the assignment
270/// but not the object containing the field.
272 const FieldDecl *FDecl;
273
274public:
276 : OriginEscapesFact(OID, EscapeKind::Field), FDecl(FDecl) {}
277
278 static bool classof(const Fact *F) {
279 return F->getKind() == Kind::OriginEscapes &&
280 static_cast<const OriginEscapesFact *>(F)->getEscapeKind() ==
282 }
283 const FieldDecl *getFieldDecl() const { return FDecl; };
284 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
285 const LoanPropagationAnalysis *LPA = nullptr) const override;
286};
287
288/// Represents that an origin escapes via assignment to global or static
289/// storage. Example: `global_storage = local_var;`
291 const VarDecl *Global;
292
293public:
295 : OriginEscapesFact(OID, EscapeKind::Global), Global(VDecl) {}
296
297 static bool classof(const Fact *F) {
298 return F->getKind() == Kind::OriginEscapes &&
299 static_cast<const OriginEscapesFact *>(F)->getEscapeKind() ==
301 }
302 const VarDecl *getGlobal() const { return Global; };
303 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
304 const LoanPropagationAnalysis *LPA = nullptr) const override;
305};
306
307/// Represents an origin escaping through the enclosing object `this`, which
308/// outlives the current method. Emitted for `this` at function exit so a borrow
309/// still held by the object there is seen as escaping -- e.g. a borrow captured
310/// via [[clang::lifetime_capture_by_this]] that outlived the captured local is
311/// reported as a use-after-scope.
313 SourceLocation Loc;
314
315public:
318
319 static bool classof(const Fact *F) {
320 return F->getKind() == Kind::OriginEscapes &&
321 static_cast<const OriginEscapesFact *>(F)->getEscapeKind() ==
323 }
324 SourceLocation getLoc() const { return Loc; }
325 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
326 const LoanPropagationAnalysis *LPA = nullptr) const override;
327};
328
329class UseFact : public Fact {
330 UseSite Site;
331 const OriginList *OList;
332
333public:
334 static bool classof(const Fact *F) { return F->getKind() == Kind::Use; }
335
336 UseFact(const Expr &UseExpr, const OriginList *OList)
337 : Fact(Kind::Use), Site(UseSite::fromExpr(UseExpr)), OList(OList) {}
338 UseFact(const UseSite &ImplicitSite, const OriginList *OList)
339 : Fact(Kind::Use), Site(ImplicitSite), OList(OList) {
340 assert(Site.getKind() != UseKind::Explicit);
341 }
342
343 const OriginList *getUsedOrigins() const { return OList; }
344 /// Null for an implicit use.
345 const Expr *getUseExpr() const { return Site.getExpr(); }
346 const UseSite &getUseSite() const { return Site; }
347
348 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
349 const LoanPropagationAnalysis *LPA = nullptr) const override;
350};
351
352/// Represents that an origin's storage has been invalidated by a container
353/// operation (e.g., vector::push_back may reallocate, invalidating iterators).
354/// Created when a container method that may invalidate references/iterators
355/// is called on the container.
357 OriginID OID;
358 const Expr *InvalidationExpr;
359
360public:
361 static bool classof(const Fact *F) {
362 return F->getKind() == Kind::InvalidateOrigin;
363 }
364
365 InvalidateOriginFact(OriginID OID, const Expr *InvalidationExpr)
366 : Fact(Kind::InvalidateOrigin), OID(OID),
367 InvalidationExpr(InvalidationExpr) {}
368
369 OriginID getInvalidatedOrigin() const { return OID; }
370 const Expr *getInvalidationExpr() const { return InvalidationExpr; }
371 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
372 const LoanPropagationAnalysis *LPA = nullptr) const override;
373};
374
375/// Top-level origin of the expression which was found to be moved, e.g, when
376/// being used as an argument to an r-value reference parameter.
377class MovedOriginFact : public Fact {
378 const OriginID MovedOrigin;
379 const Expr *MoveExpr;
380
381public:
382 static bool classof(const Fact *F) {
383 return F->getKind() == Kind::MovedOrigin;
384 }
385
386 MovedOriginFact(const Expr *MoveExpr, OriginID MovedOrigin)
387 : Fact(Kind::MovedOrigin), MovedOrigin(MovedOrigin), MoveExpr(MoveExpr) {}
388
389 OriginID getMovedOrigin() const { return MovedOrigin; }
390 const Expr *getMoveExpr() const { return MoveExpr; }
391
392 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
393 const LoanPropagationAnalysis *LPA = nullptr) const override;
394};
395
396/// A dummy-fact used to mark a specific point in the code for testing.
397/// It is generated by recognizing a `void("__lifetime_test_point_...")` cast.
398class TestPointFact : public Fact {
399 StringRef Annotation;
400
401public:
402 static bool classof(const Fact *F) { return F->getKind() == Kind::TestPoint; }
403
404 explicit TestPointFact(StringRef Annotation)
405 : Fact(Kind::TestPoint), Annotation(Annotation) {}
406
407 StringRef getAnnotation() const { return Annotation; }
408
409 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &,
410 const LoanPropagationAnalysis *LPA = nullptr) const override;
411};
412
413/// All loans are cleared from an origin (e.g., assigning a callable without
414/// tracked origins to std::function).
415class KillOriginFact : public Fact {
416 OriginID OID;
417
418public:
419 static bool classof(const Fact *F) {
420 return F->getKind() == Kind::KillOrigin;
421 }
422
424
425 OriginID getKilledOrigin() const { return OID; }
426
427 void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM,
428 const LoanPropagationAnalysis *LPA = nullptr) const override;
429};
430
432public:
433 FactManager(const AnalysisDeclContext &AC, const CFG &Cfg) : OriginMgr(AC) {
434 BlockToFacts.resize(Cfg.getNumBlockIDs());
435 }
436
438 return BlockToFacts[B->getBlockID()];
439 }
440
442 if (!NewFacts.empty())
443 BlockToFacts[B->getBlockID()].assign(NewFacts.begin(), NewFacts.end());
444 }
445
446 void appendBlockFact(const CFGBlock *B, const Fact *F) {
447 BlockToFacts[B->getBlockID()].push_back(F);
448 }
449
450 template <typename FactType, typename... Args>
451 FactType *createFact(Args &&...args) {
452 void *Mem = FactAllocator.Allocate<FactType>();
453 FactType *Res = new (Mem) FactType(std::forward<Args>(args)...);
454 Res->setID(NextFactID++);
455 return Res;
456 }
457
458 void dump(const CFG &Cfg, AnalysisDeclContext &AC,
459 const LoanPropagationAnalysis *LPA = nullptr) const;
460
461 /// Retrieves program points that were specially marked in the source code
462 /// for testing.
463 ///
464 /// The analysis recognizes special function calls of the form
465 /// `void("__lifetime_test_point_<name>")` as test points. This method returns
466 /// a map from the annotation string (<name>) to the corresponding
467 /// `ProgramPoint`. This allows test harnesses to query the analysis state at
468 /// user-defined locations in the code.
469 /// \note This is intended for testing only.
470 llvm::StringMap<ProgramPoint> getTestPoints() const;
471 /// Retrieves all the facts in the block containing Program Point P.
472 /// \note This is intended for testing only.
474 size_t getBlockID(ProgramPoint P) const;
475
476 unsigned getNumFacts() const { return NextFactID.Value; }
477
478 /// Returns the origins that are referenced from more than one basic block.
479 /// Only those need to survive block boundaries in the dataflow analyses; the
480 /// rest are block-local.
481 const llvm::BitVector &getPersistentOrigins() const {
482 assert(PersistentOrigins.size() == OriginMgr.getNumOrigins() &&
483 "persistent origins have not been computed");
484 return PersistentOrigins;
485 }
486
487 LoanManager &getLoanMgr() { return LoanMgr; }
488 const LoanManager &getLoanMgr() const { return LoanMgr; }
489 OriginManager &getOriginMgr() { return OriginMgr; }
490 const OriginManager &getOriginMgr() const { return OriginMgr; }
491
492 void addCapturedField(const FieldDecl *FD) { CapturedFields.insert(FD); }
493 bool isFieldCapturedByLambda(const FieldDecl *FD) const {
494 return IsThisCapturedByLambda || CapturedFields.contains(FD);
495 }
496 void setThisCapturedByLambda() { IsThisCapturedByLambda = true; }
497
498private:
499 /// Classifies every origin as persistent or block-local. Called by
500 /// `FactsGenerator` once all facts and origins have been created.
501 void computePersistentOrigins(const CFG &Cfg);
502
503 friend class FactsGenerator;
504
505 FactID NextFactID{0};
506 LoanManager LoanMgr;
507 OriginManager OriginMgr;
508 /// Facts for each CFG block, indexed by block ID.
510 llvm::BumpPtrAllocator FactAllocator;
511 /// Bit vector indexed by origin ID. If set, the origin is referenced from
512 /// more than one basic block and must participate in join operations. If
513 /// unset, the origin is block-local and can be discarded at block
514 /// boundaries.
515 ///
516 /// Shared by every analysis so that they all agree on which origins cross
517 /// block boundaries.
518 llvm::BitVector PersistentOrigins;
519
520 /// Set of field declarations that are explicitly or init-captured in any
521 /// lambda within the analyzed function.
522 llvm::DenseSet<const FieldDecl *> CapturedFields;
523 /// Whether the 'this' pointer is captured by any lambda within the analyzed
524 /// function. When true, any field of 'this' is considered captured.
525 bool IsThisCapturedByLambda = false;
526};
527} // namespace clang::lifetimes::internal
528
529#endif // LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_FACTS_H
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Represents a single basic block in a source-level CFG.
Definition CFG.h:651
unsigned getBlockID() const
Definition CFG.h:1177
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Definition CFG.h:1294
unsigned getNumBlockIDs() const
Returns the total number of BlockIDs allocated (which start at 0).
Definition CFG.h:1487
This represents one expression.
Definition Expr.h:114
Represents a member of a struct/union/class.
Definition Decl.h:3341
Encodes a location in the source.
A trivial tuple used to represent a source range.
Represents a variable declaration or definition.
Definition Decl.h:934
Where and how an origin is used, for diagnostics.
Definition Facts.h:40
static UseSite scopeExit(SourceLocation Loc, const VarDecl &VD, UseKind Kind)
Definition Facts.h:60
UseKind getKind() const
Definition Facts.h:67
const Expr * getExpr() const
Null for an implicit use or one known only by its location.
Definition Facts.h:69
SourceRange getRange() const
Empty unless there is a use expression.
Definition Facts.h:82
SourceLocation getLoc() const
Definition Facts.h:76
const VarDecl * getScopeExitVD() const
The variable destroyed or cleaned up, for implicit uses.
Definition Facts.h:73
static UseSite at(SourceLocation Loc)
Definition Facts.h:57
static UseSite fromExpr(const Expr &E)
Definition Facts.h:54
Represents the storage location being borrowed, e.g., a specific stack variable or a field within it:...
Definition Loans.h:127
const AccessPath & getAccessPath() const
Definition Facts.h:192
SourceLocation getExpiryLoc() const
Definition Facts.h:194
static bool classof(const Fact *F)
Definition Facts.h:186
ExpireFact(AccessPath AP, SourceLocation ExpiryLoc, std::optional< OriginID > OID=std::nullopt)
Definition Facts.h:188
std::optional< OriginID > getOriginID() const
Definition Facts.h:193
void dump(llvm::raw_ostream &OS, const LoanManager &LM, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:88
llvm::ArrayRef< const Fact * > getFacts(const CFGBlock *B) const
Definition Facts.h:437
FactType * createFact(Args &&...args)
Definition Facts.h:451
bool isFieldCapturedByLambda(const FieldDecl *FD) const
Definition Facts.h:493
llvm::StringMap< ProgramPoint > getTestPoints() const
Retrieves program points that were specially marked in the source code for testing.
Definition Facts.cpp:203
void dump(const CFG &Cfg, AnalysisDeclContext &AC, const LoanPropagationAnalysis *LPA=nullptr) const
Definition Facts.cpp:218
void addBlockFacts(const CFGBlock *B, llvm::ArrayRef< Fact * > NewFacts)
Definition Facts.h:441
const OriginManager & getOriginMgr() const
Definition Facts.h:490
size_t getBlockID(ProgramPoint P) const
Definition Facts.cpp:242
void appendBlockFact(const CFGBlock *B, const Fact *F)
Definition Facts.h:446
const LoanManager & getLoanMgr() const
Definition Facts.h:488
llvm::ArrayRef< const Fact * > getBlockContaining(ProgramPoint P) const
Retrieves all the facts in the block containing Program Point P.
Definition Facts.cpp:238
const llvm::BitVector & getPersistentOrigins() const
Returns the origins that are referenced from more than one basic block.
Definition Facts.h:481
void addCapturedField(const FieldDecl *FD)
Definition Facts.h:492
FactManager(const AnalysisDeclContext &AC, const CFG &Cfg)
Definition Facts.h:433
An abstract base class for a single, atomic lifetime-relevant event.
Definition Facts.h:99
virtual void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &, const LoanPropagationAnalysis *LPA=nullptr) const
Definition Facts.cpp:73
@ InvalidateOrigin
An origin is invalidated (e.g. vector resized, delete called).
Definition Facts.h:122
@ TestPoint
A marker for a specific point in the code, for testing.
Definition Facts.h:118
@ Expire
A loan expires as its underlying storage is freed (e.g., variable goes out of scope).
Definition Facts.h:107
@ Issue
A new loan is issued from a borrow expression (e.g., &x).
Definition Facts.h:104
@ OriginFlow
An origin is propagated from a source to a destination (e.g., p = q).
Definition Facts.h:112
@ MovedOrigin
An origin that is moved (e.g., passed to an rvalue reference parameter).
Definition Facts.h:116
@ Use
An origin is used (eg. appears as l-value expression like DeclRefExpr).
Definition Facts.h:114
@ OriginEscapes
An origin that escapes the function scope (e.g., via return).
Definition Facts.h:120
@ KillOrigin
All loans of an origin are cleared.
Definition Facts.h:124
const T * getAs() const
Definition Facts.h:141
FieldEscapeFact(OriginID OID, const FieldDecl *FDecl)
Definition Facts.h:275
const FieldDecl * getFieldDecl() const
Definition Facts.h:283
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:142
static bool classof(const Fact *F)
Definition Facts.h:278
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:150
GlobalEscapeFact(OriginID OID, const VarDecl *VDecl)
Definition Facts.h:294
static bool classof(const Fact *F)
Definition Facts.h:297
const VarDecl * getGlobal() const
Definition Facts.h:302
InvalidateOriginFact(OriginID OID, const Expr *InvalidationExpr)
Definition Facts.h:365
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:181
void dump(llvm::raw_ostream &OS, const LoanManager &LM, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:78
IssueFact(LoanID LID, OriginID OID)
Definition Facts.h:166
static bool classof(const Fact *F)
Definition Facts.h:164
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:195
static bool classof(const Fact *F)
Definition Facts.h:419
Manages the creation, storage and retrieval of loans.
Definition Loans.h:233
static bool classof(const Fact *F)
Definition Facts.h:382
MovedOriginFact(const Expr *MoveExpr, OriginID MovedOrigin)
Definition Facts.h:386
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:126
enum clang::lifetimes::internal::OriginEscapesFact::EscapeKind EscKind
EscapeKind
The way an origin can escape the current scope.
Definition Facts.h:232
@ Global
Escapes via assignment to a field.
Definition Facts.h:235
@ This
Escapes via assignment to global storage.
Definition Facts.h:236
static bool classof(const Fact *F)
Definition Facts.h:240
OriginEscapesFact(OriginID OID, EscapeKind EscKind)
Definition Facts.h:244
static bool classof(const Fact *F)
Definition Facts.h:209
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:100
OriginFlowFact(OriginID OIDDest, OriginID OIDSrc, bool KillDest)
Definition Facts.h:213
A list of origins representing levels of indirection for pointer-like types.
Definition Origins.h:105
Manages the creation, storage, and retrieval of origins for pointer-like variables and expressions.
Definition Origins.h:135
static bool classof(const Fact *F)
Definition Facts.h:258
ReturnEscapeFact(OriginID OID, const Expr *ReturnExpr)
Definition Facts.h:255
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:134
static bool classof(const Fact *F)
Definition Facts.h:402
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:189
TestPointFact(StringRef Annotation)
Definition Facts.h:404
ThisEscapeFact(OriginID OID, SourceLocation Loc)
Definition Facts.h:316
static bool classof(const Fact *F)
Definition Facts.h:319
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:158
UseFact(const UseSite &ImplicitSite, const OriginList *OList)
Definition Facts.h:338
const Expr * getUseExpr() const
Null for an implicit use.
Definition Facts.h:345
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM, const LoanPropagationAnalysis *LPA=nullptr) const override
Definition Facts.cpp:166
static bool classof(const Fact *F)
Definition Facts.h:334
UseFact(const Expr &UseExpr, const OriginList *OList)
Definition Facts.h:336
const UseSite & getUseSite() const
Definition Facts.h:346
const OriginList * getUsedOrigins() const
Definition Facts.h:343
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
Definition Facts.h:157
utils::ID< struct LoanTag > LoanID
Definition Loans.h:27
utils::ID< struct OriginTag > OriginID
Definition Origins.h:28
utils::ID< struct FactTag > FactID
Definition Facts.h:96
UseKind
How an origin is used: by an expression, or implicitly at scope exit by a destructor or a cleanup cal...
Definition Facts.h:37
const FunctionProtoType * T
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t __builtin_riscv_mhacc_i32 __builtin_riscv_mhaccu_u32 __builtin_riscv_mhaccsu_i32 __builtin_riscv_mulq_i32 __builtin_riscv_mqwacc_i64 uint8_t
A generic, type-safe wrapper for an ID, distinguished by its Tag type.
Definition Utils.h:21