clang
22.0.0git
include
clang
Analysis
Analyses
LifetimeSafety
LoanPropagation.h
Go to the documentation of this file.
1
//===- LoanPropagation.h - Loan Propagation Analysis -----------*- 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 the LoanPropagationAnalysis, a forward dataflow analysis
10
// that tracks which loans each origin holds at each program point. Loans
11
// represent borrows of storage locations and are propagated through the
12
// program as pointers are copied or assigned.
13
//
14
//===----------------------------------------------------------------------===//
15
#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_LOAN_PROPAGATION_H
16
#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_LOAN_PROPAGATION_H
17
18
#include "
clang/Analysis/Analyses/LifetimeSafety/Facts.h
"
19
#include "
clang/Analysis/AnalysisDeclContext.h
"
20
#include "
clang/Analysis/CFG.h
"
21
#include "llvm/ADT/ImmutableMap.h"
22
#include "llvm/ADT/ImmutableSet.h"
23
24
namespace
clang::lifetimes::internal
{
25
26
// Using LLVM's immutable collections is efficient for dataflow analysis
27
// as it avoids deep copies during state transitions.
28
// TODO(opt): Consider using a bitset to represent the set of loans.
29
using
LoanSet
= llvm::ImmutableSet<LoanID>;
30
using
OriginLoanMap
= llvm::ImmutableMap<OriginID, LoanSet>;
31
32
class
LoanPropagationAnalysis
{
33
public
:
34
LoanPropagationAnalysis
(
const
CFG
&
C
,
AnalysisDeclContext
&AC,
FactManager
&F,
35
OriginLoanMap::Factory &OriginLoanMapFactory,
36
LoanSet::Factory &LoanSetFactory);
37
~LoanPropagationAnalysis
();
38
39
LoanSet
getLoans
(
OriginID
OID,
ProgramPoint
P)
const
;
40
41
private
:
42
class
Impl
;
43
std::unique_ptr<Impl> PImpl;
44
};
45
46
}
// namespace clang::lifetimes::internal
47
48
#endif
// LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_LOAN_PROPAGATION_H
AnalysisDeclContext.h
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
CFG.h
Facts.h
clang::AnalysisDeclContext
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Definition
AnalysisDeclContext.h:72
clang::CFG
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Definition
CFG.h:1222
clang::lifetimes::internal::FactManager
Definition
Facts.h:185
clang::lifetimes::internal::LoanPropagationAnalysis::Impl
Definition
LoanPropagation.cpp:120
clang::lifetimes::internal::LoanPropagationAnalysis::getLoans
LoanSet getLoans(OriginID OID, ProgramPoint P) const
Definition
LoanPropagation.cpp:135
clang::lifetimes::internal::LoanPropagationAnalysis::~LoanPropagationAnalysis
~LoanPropagationAnalysis()
clang::lifetimes::internal::LoanPropagationAnalysis::LoanPropagationAnalysis
LoanPropagationAnalysis(const CFG &C, AnalysisDeclContext &AC, FactManager &F, OriginLoanMap::Factory &OriginLoanMapFactory, LoanSet::Factory &LoanSetFactory)
Definition
LoanPropagation.cpp:124
clang::lifetimes::internal
Definition
Checker.h:23
clang::lifetimes::internal::ProgramPoint
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
Definition
Facts.h:74
clang::lifetimes::internal::LoanSet
llvm::ImmutableSet< LoanID > LoanSet
Definition
LoanPropagation.h:29
clang::lifetimes::internal::OriginID
utils::ID< struct OriginTag > OriginID
Definition
Origins.h:23
clang::lifetimes::internal::OriginLoanMap
llvm::ImmutableMap< OriginID, LoanSet > OriginLoanMap
Definition
LoanPropagation.h:30
clang::LinkageSpecLanguageIDs::C
@ C
Definition
DeclCXX.h:3007
Generated on
for clang by
1.14.0