clang 17.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"
20
21namespace clang {
22namespace dataflow {
23
24/// Maps statements to the environments of basic blocks that contain them.
26public:
27 virtual ~StmtToEnvMap() = default;
28
29 /// Retrieves the environment of the basic block that contains `S`.
30 /// If `S` is reachable, returns a non-null pointer to the environment.
31 /// If `S` is not reachable, returns nullptr.
32 virtual const Environment *getEnvironment(const Stmt &S) const = 0;
33};
34
35/// Evaluates `S` and updates `Env` accordingly.
36///
37/// Requirements:
38///
39/// `S` must not be `ParenExpr` or `ExprWithCleanups`.
40void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env);
41
42} // namespace dataflow
43} // namespace clang
44
45#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TRANSFER_H
Stmt - This represents one statement.
Definition: Stmt.h:72
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:25
virtual ~StmtToEnvMap()=default
virtual const Environment * getEnvironment(const Stmt &S) const =0
Retrieves the environment of the basic block that contains S.
void transfer(const StmtToEnvMap &StmtToEnv, const Stmt &S, Environment &Env)
Evaluates S and updates Env accordingly.
Definition: Transfer.cpp:877