27#include "llvm/ADT/FoldingSet.h"
28#include "llvm/Support/Debug.h"
29#include "llvm/Support/ErrorHandling.h"
30#include "llvm/Support/TimeProfiler.h"
41 if (
const auto *ND = dyn_cast<NamedDecl>(D))
42 Name = ND->getQualifiedNameAsString();
47 DEBUG_WITH_TYPE(Name.c_str(), FactMgr.
dump(Cfg, AC));
53 : AC(AC), Reporter(Reporter) {}
56 llvm::TimeTraceScope TimeProfile(
"LifetimeSafetyAnalysis");
58 const CFG &Cfg = *AC.getCFG();
59 DEBUG_WITH_TYPE(
"PrintCFG", Cfg.
dump(AC.getASTContext().getLangOpts(),
62 FactMgr = std::make_unique<FactManager>(AC, Cfg);
67 DEBUG_WITH_TYPE(
"LifetimeFacts", FactMgr->dump(Cfg, AC));
71 DEBUG_WITH_TYPE(
"EnableFilterByFunctionName",
85 LoanPropagation = std::make_unique<LoanPropagationAnalysis>(
86 Cfg, AC, *FactMgr, Factory.OriginMapFactory, Factory.LoanSetFactory);
88 LiveOrigins = std::make_unique<LiveOriginsAnalysis>(
89 Cfg, AC, *FactMgr, Factory.LivenessMapFactory);
90 DEBUG_WITH_TYPE(
"LiveOrigins",
91 LiveOrigins->dump(llvm::dbgs(), FactMgr->getTestPoints()));
99 if (FunctionBody ==
nullptr)
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
C Language Family Type Representation.
const LangOptions & getLangOpts() const
AnalysisDeclContext contains the context data for the function, method or block under analysis.
const Decl * getDecl() const
ASTContext & getASTContext() const
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
void dump(const LangOptions &LO, bool ShowColors) const
dump - A simple pretty printer of a CFG that outputs to stderr.
Decl - This represents one declaration (or definition), e.g.
Stmt - This represents one statement.
OriginManager & getOriginMgr()
void dump(const CFG &Cfg, AnalysisDeclContext &AC) const
Running the lifetime safety analysis and querying its results.
FactManager & getFactManager()
LifetimeSafetyAnalysis(AnalysisDeclContext &AC, LifetimeSafetyReporter *Reporter)
Manages the creation, storage, and retrieval of origins for pointer-like variables and expressions.
void collectMissingOrigins(Stmt &FunctionBody, LifetimeSafetyStats &LSStats)
Collects statistics about expressions that lack associated origins.
static void DebugOnlyFunction(AnalysisDeclContext &AC, const CFG &Cfg, FactManager &FactMgr)
void runLifetimeChecker(const LoanPropagationAnalysis &LoanPropagation, const LiveOriginsAnalysis &LiveOrigins, const FactManager &FactMgr, AnalysisDeclContext &ADC, LifetimeSafetyReporter *Reporter)
Runs the lifetime checker, which detects use-after-free errors by examining loan expiration points an...
void collectLifetimeStats(AnalysisDeclContext &AC, OriginManager &OM, LifetimeSafetyStats &Stats)
void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC, LifetimeSafetyReporter *Reporter, LifetimeSafetyStats &Stats, bool CollectStats)
The main entry point for the analysis.
A structure to hold the statistics related to LifetimeAnalysis.