14#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_FACTS_H
15#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_FACTS_H
21#include "llvm/ADT/SmallVector.h"
22#include "llvm/Support/Debug.h"
30 enum class Kind : uint8_t {
59 template <
typename T>
const T *
getAs()
const {
61 return static_cast<const T *
>(
this);
121 KillDest(KillDest) {}
149 bool IsWritten =
false;
171 StringRef Annotation;
188 auto It = BlockToFactsMap.find(B);
189 if (It != BlockToFactsMap.end())
195 if (!NewFacts.empty())
196 BlockToFactsMap[B].assign(NewFacts.begin(), NewFacts.end());
199 template <
typename FactType,
typename... Args>
201 void *Mem = FactAllocator.Allocate<FactType>();
202 return new (Mem) FactType(std::forward<Args>(args)...);
226 llvm::DenseMap<const clang::CFGBlock *, llvm::SmallVector<const Fact *>>
228 llvm::BumpPtrAllocator FactAllocator;
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.
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
This represents one expression.
Encodes a location in the source.
SourceLocation getExpiryLoc() const
static bool classof(const Fact *F)
ExpireFact(LoanID LID, SourceLocation ExpiryLoc)
void dump(llvm::raw_ostream &OS, const LoanManager &LM, const OriginManager &) const override
llvm::ArrayRef< const Fact * > getFacts(const CFGBlock *B) const
FactType * createFact(Args &&...args)
OriginManager & getOriginMgr()
llvm::StringMap< ProgramPoint > getTestPoints() const
Retrieves program points that were specially marked in the source code for testing.
void dump(const CFG &Cfg, AnalysisDeclContext &AC) const
LoanManager & getLoanMgr()
void addBlockFacts(const CFGBlock *B, llvm::ArrayRef< Fact * > NewFacts)
const OriginManager & getOriginMgr() const
const LoanManager & getLoanMgr() const
An abstract base class for a single, atomic lifetime-relevant event.
@ TestPoint
A marker for a specific point in the code, for testing.
@ Expire
A loan expires as its underlying storage is freed (e.g., variable goes out of scope).
@ ReturnOfOrigin
An origin escapes the function by flowing into the return value.
@ Issue
A new loan is issued from a borrow expression (e.g., &x).
@ OriginFlow
An origin is propagated from a source to a destination (e.g., p = q).
@ Use
An origin is used (eg. appears as l-value expression like DeclRefExpr).
virtual void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &) const
void dump(llvm::raw_ostream &OS, const LoanManager &LM, const OriginManager &OM) const override
OriginID getOriginID() const
IssueFact(LoanID LID, OriginID OID)
static bool classof(const Fact *F)
Manages the creation, storage and retrieval of loans.
static bool classof(const Fact *F)
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM) const override
OriginID getSrcOriginID() const
OriginID getDestOriginID() const
OriginFlowFact(OriginID OIDDest, OriginID OIDSrc, bool KillDest)
Manages the creation, storage, and retrieval of origins for pointer-like variables and expressions.
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM) const override
ReturnOfOriginFact(OriginID OID)
OriginID getReturnedOriginID() const
static bool classof(const Fact *F)
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &) const override
static bool classof(const Fact *F)
StringRef getAnnotation() const
TestPointFact(StringRef Annotation)
const Expr * getUseExpr() const
void dump(llvm::raw_ostream &OS, const LoanManager &, const OriginManager &OM) const override
OriginID getUsedOrigin(const OriginManager &OM) const
UseFact(const Expr *UseExpr)
static bool classof(const Fact *F)
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
utils::ID< struct LoanTag > LoanID
utils::ID< struct OriginTag > OriginID
const FunctionProtoType * T