clang 20.0.0git
Classes | Namespaces | Typedefs | Functions | Variables
DataflowAnalysis.h File Reference
#include <iterator>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>
#include "clang/AST/ASTContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/Analysis/FlowSensitive/AdornedCFG.h"
#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
#include "clang/Analysis/FlowSensitive/DataflowLattice.h"
#include "clang/Analysis/FlowSensitive/MatchSwitch.h"
#include "clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h"
#include "clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"

Go to the source code of this file.

Classes

class  clang::dataflow::DataflowAnalysis< Derived, LatticeT >
 Base class template for dataflow analyses built on a single lattice type. More...
 
struct  clang::dataflow::DataflowAnalysisState< LatticeT >
 
struct  clang::dataflow::CFGEltCallbacks< AnalysisT >
 A pair of callbacks to be called with the state before and after visiting a CFG element. More...
 
struct  clang::dataflow::DiagnosisCallbacks< AnalysisT, Diagnostic >
 A pair of callbacks for performing diagnosis on a CFG element, called with the state before and after visiting that CFG element. More...
 
class  clang::dataflow::DataflowModel
 Abstract base class for dataflow "models": reusable analysis components that model a particular aspect of program semantics in the Environment. More...
 

Namespaces

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.
 
namespace  clang::dataflow
 Dataflow Directional Tag Classes.
 

Typedefs

template<typename AnalysisT >
using clang::dataflow::CFGEltCallback = std::function< void(const CFGElement &, const DataflowAnalysisState< typename AnalysisT::Lattice > &)>
 A callback to be called with the state before or after visiting a CFG element.
 
template<typename AnalysisT , typename Diagnostic >
using clang::dataflow::DiagnosisCallback = llvm::function_ref< llvm::SmallVector< Diagnostic >(const CFGElement &, ASTContext &, const TransferStateForDiagnostics< typename AnalysisT::Lattice > &)>
 A callback for performing diagnosis on a CFG element, called with the state before or after visiting that CFG element.
 

Functions

template<typename AnalysisT >
llvm::Expected< std::vector< std::optional< DataflowAnalysisState< typename AnalysisT::Lattice > > > > clang::dataflow::runDataflowAnalysis (const AdornedCFG &ACFG, AnalysisT &Analysis, const Environment &InitEnv, CFGEltCallbacks< AnalysisT > PostAnalysisCallbacks={}, std::int32_t MaxBlockVisits=kDefaultMaxBlockVisits)
 Performs dataflow analysis and returns a mapping from basic block IDs to dataflow analysis states that model the respective basic blocks.
 
template<typename AnalysisT >
auto clang::dataflow::createAnalysis (ASTContext &ASTCtx, Environment &Env) -> decltype(AnalysisT(ASTCtx, Env))
 
template<typename AnalysisT , typename Diagnostic >
llvm::Expected< llvm::SmallVector< Diagnostic > > clang::dataflow::diagnoseFunction (const FunctionDecl &FuncDecl, ASTContext &ASTCtx, DiagnosisCallbacks< AnalysisT, Diagnostic > Diagnoser, std::int64_t MaxSATIterations=kDefaultMaxSATIterations, std::int32_t MaxBlockVisits=kDefaultMaxBlockVisits)
 Runs a dataflow analysis over the given function and then runs Diagnoser over the results.
 
template<typename AnalysisT , typename Diagnostic >
llvm::Expected< llvm::SmallVector< Diagnostic > > clang::dataflow::diagnoseFunction (const FunctionDecl &FuncDecl, ASTContext &ASTCtx, DiagnosisCallback< AnalysisT, Diagnostic > Diagnoser, std::int64_t MaxSATIterations=kDefaultMaxSATIterations, std::int32_t MaxBlockVisits=kDefaultMaxBlockVisits)
 Overload that takes only one diagnosis callback, which is run on the state after visiting the CFGElement.
 

Variables

constexpr std::int64_t clang::dataflow::kDefaultMaxSATIterations = 1'000'000'000
 Default for the maximum number of SAT solver iterations during analysis.
 
constexpr std::int32_t clang::dataflow::kDefaultMaxBlockVisits = 20'000
 Default for the maximum number of block visits during analysis.