clang 20.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:
28 // `CurBlockID` is the ID of the block currently being processed, and
29 // `CurState` is the pending state currently associated with this block. These
30 // are supplied separately as the pending state for the current block may not
31 // yet be represented in `BlockToState`.
33 llvm::ArrayRef<std::optional<TypeErasedDataflowAnalysisState>>
34 BlockToState,
35 unsigned CurBlockID,
36 const TypeErasedDataflowAnalysisState &CurState)
37 : ACFG(ACFG), BlockToState(BlockToState), CurBlockID(CurBlockID),
38 CurState(CurState) {}
39
40 /// Returns the environment of the basic block that contains `S`.
41 /// The result is guaranteed never to be null.
42 const Environment *getEnvironment(const Stmt &S) const;
43
44private:
45 const AdornedCFG &ACFG;
47 unsigned CurBlockID;
48 const TypeErasedDataflowAnalysisState &CurState;
49};
50
51/// Evaluates `S` and updates `Env` accordingly.
52///
53/// Requirements:
54///
55/// `S` must not be `ParenExpr` or `ExprWithCleanups`.
56void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env,
57 Environment::ValueModel &Model);
58
59} // namespace dataflow
60} // namespace clang
61
62#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H
const Environment & Env
Definition: HTMLLogger.cpp:148
Stmt - This represents one statement.
Definition: Stmt.h:84
Holds CFG with additional information derived from it that is needed to perform dataflow analysis.
Definition: AdornedCFG.h:47
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:42
StmtToEnvMap(const AdornedCFG &ACFG, llvm::ArrayRef< std::optional< TypeErasedDataflowAnalysisState > > BlockToState, unsigned CurBlockID, const TypeErasedDataflowAnalysisState &CurState)
Definition: Transfer.h:32
void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env, Environment::ValueModel &Model)
Evaluates S and updates Env accordingly.
Definition: Transfer.cpp:890
The JSON file list parser is used to communicate input to InstallAPI.
Type-erased model of the program at a given program point.