clang 22.0.0git
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
20#include "clang/Analysis/CFG.h"
21#include "llvm/ADT/ImmutableMap.h"
22#include "llvm/ADT/ImmutableSet.h"
23
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.
29using LoanSet = llvm::ImmutableSet<LoanID>;
30using OriginLoanMap = llvm::ImmutableMap<OriginID, LoanSet>;
31
33public:
35 OriginLoanMap::Factory &OriginLoanMapFactory,
36 LoanSet::Factory &LoanSetFactory);
38
40
41private:
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
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 source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Definition CFG.h:1222
LoanSet getLoans(OriginID OID, ProgramPoint P) const
LoanPropagationAnalysis(const CFG &C, AnalysisDeclContext &AC, FactManager &F, OriginLoanMap::Factory &OriginLoanMapFactory, LoanSet::Factory &LoanSetFactory)
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
Definition Facts.h:74
llvm::ImmutableSet< LoanID > LoanSet
utils::ID< struct OriginTag > OriginID
Definition Origins.h:23
llvm::ImmutableMap< OriginID, LoanSet > OriginLoanMap