clang 18.0.0git
Transfer.h
Go to the documentation of this file.
1//===-- Transfer.h ----------------------------------------------*- 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 a transfer function that evaluates a program statement and
10// updates an environment accordingly.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H
15#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H
16
17#include "clang/AST/Stmt.h"
21
22namespace clang {
23namespace dataflow {
24
25/// Maps statements to the environments of basic blocks that contain them.
27public:
29 llvm::ArrayRef<std::optional<TypeErasedDataflowAnalysisState>>
30 BlockToState)
31 : CFCtx(CFCtx), BlockToState(BlockToState) {}
32
33 /// Returns the environment of the basic block that contains `S`.
34 /// The result is guaranteed never to be null.
35 const Environment *getEnvironment(const Stmt &S) const;
36
37private:
38 const ControlFlowContext &CFCtx;
40};
41
42/// Evaluates `S` and updates `Env` accordingly.
43///
44/// Requirements:
45///
46/// `S` must not be `ParenExpr` or `ExprWithCleanups`.
47void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env);
48
49} // namespace dataflow
50} // namespace clang
51
52#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H
const Environment & Env
Definition: HTMLLogger.cpp:145
const ControlFlowContext & CFCtx
Contains the CFG being analyzed.
Stmt - This represents one statement.
Definition: Stmt.h:72
Holds CFG and other derived context that is needed to perform dataflow analysis.
Holds the state of the program (store and heap) at a given program point.
Maps statements to the environments of basic blocks that contain them.
Definition: Transfer.h:26
const Environment * getEnvironment(const Stmt &S) const
Returns the environment of the basic block that contains S.
Definition: Transfer.cpp:40
StmtToEnvMap(const ControlFlowContext &CFCtx, llvm::ArrayRef< std::optional< TypeErasedDataflowAnalysisState > > BlockToState)
Definition: Transfer.h:28
void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env)
Evaluates S and updates Env accordingly.
Definition: Transfer.cpp:822