14#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_COREENGINE_H
15#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_COREENGINE_H
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/ADT/iterator_range.h"
29#include "llvm/Support/Casting.h"
57 std::vector<std::pair<BlockEdge, const ExplodedNode *>>;
60 std::vector<std::pair<const CFGBlock *, const ExplodedNode *>>;
71 std::unique_ptr<WorkList> WList;
72 std::unique_ptr<WorkList> CTUWList;
123 std::optional<unsigned> getCompletedIterationCount(
const CFGBlock *B,
158 blocksAborted.push_back(std::make_pair(block, node));
165 return llvm::iterator_range(blocksExhausted);
175 bool MarkAsSink =
false)
const {
185 State = State->BindExpr(E, SF,
V);
222 : Eng(E), Block(B), SF(S) {
241 return Eng.WList->getBlockCounter().getNumVisited(SF, Block->getBlockID());
331 for (
const auto I : S)
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Stores options for the analyzer from the command line.
Represents a single basic block in a source-level CFG.
Represents binding an expression to a temporary.
Represents a point when we begin processing an inlined call.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
This represents one expression.
Represents the declaration of a label.
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, const StackFrame *SF, const ProgramPointTag *tag)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
It represents a stack frame of the call stack.
Stmt - This represents one statement.
An abstract data type used to count the number of times a given block has been visited along a path a...
CoreEngine - Implements the core logic of the graph-reachability analysis.
void addAbortedBlock(const ExplodedNode *node, const CFGBlock *block)
Inform the CoreEngine that a basic block was aborted because it could not be completely analyzed.
CoreEngine(ExprEngine &exprengine, FunctionSummariesTy *FS, AnalyzerOptions &Opts)
Construct a CoreEngine object to analyze the provided CFG.
DataTag::Factory & getDataTags()
void enqueueStmtNode(ExplodedNode *N, const CFGBlock *Block, unsigned Idx)
Enqueue a single node created as a result of statement processing.
bool wasBlockAborted() const
CoreEngine & operator=(const CoreEngine &)=delete
void dispatchWorkItem(ExplodedNode *Pred, ProgramPoint Loc, const WorkListUnit &WU)
Dispatch the work list item based on the given location information.
std::vector< std::pair< const CFGBlock *, const ExplodedNode * > > BlocksAborted
WorkList * getCTUWorkList() const
bool wasBlocksExhausted() const
WorkList * getWorkList() const
void enqueueStmtNodes(ExplodedNodeSet &Set, const CFGBlock *Block, unsigned Idx)
Enqueue nodes that were created as a result of processing a statement onto the work list.
CoreEngine(const CoreEngine &)=delete
std::vector< std::pair< BlockEdge, const ExplodedNode * > > BlocksExhausted
friend class NodeBuilderContext
bool ExecuteWorkList(const StackFrame *SF, unsigned Steps, ProgramStateRef InitState)
ExecuteWorkList - Run the worklist algorithm for a maximum number of steps.
ExplodedNode * makePostStmtNode(const Stmt *S, ProgramStateRef State, ExplodedNode *Pred, bool MarkAsSink=false) const
auto exhausted_blocks() const
bool hasWorkRemaining() const
ExplodedGraph & getGraph()
getGraph - Returns the exploded graph.
ExplodedNode * makeNodeWithBinding(ExplodedNode *Pred, const Expr *E, SVal V, ProgramPoint::Kind K=ProgramPoint::PostStmtKind) const
ExplodedNode * makeNodeWithBinding(ExplodedNode *Pred, const Expr *E, SVal V, ProgramStateRef State, ProgramPoint::Kind K=ProgramPoint::PostStmtKind) const
void enqueueEndOfFunction(ExplodedNodeSet &Set, const ReturnStmt *RS)
enqueue the nodes corresponding to the end of function onto the end of path / work list.
auto aborted_blocks() const
ExplodedNode * makeNode(const ProgramPoint &Loc, ProgramStateRef State, ExplodedNode *Pred, bool MarkAsSink=false) const
void enqueue(ExplodedNodeSet &Set)
Enqueue the given set of nodes onto the work list.
ExplodedNodeSet is a set of ExplodedNode * elements with the invariant that its elements cannot be nu...
const ProgramStateRef & getState() const
const StackFrame * getStackFrame() const
const CoreEngine & getEngine() const
Return the CoreEngine associated with this builder.
const CFGBlock * getBlock() const
Return the CFGBlock associated with this builder.
NodeBuilderContext(const CoreEngine &E, const CFGBlock *B, ExplodedNode *N)
NodeBuilderContext(const CoreEngine &E, const CFGBlock *B, const StackFrame *S)
unsigned blockCount() const
Returns the number of times the current basic block has been visited on the exploded graph path.
const StackFrame * getStackFrame() const
Return the stack frame associated with this builder.
const NodeBuilderContext & C
void takeNodes(ExplodedNode *N)
NodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet, const NodeBuilderContext &Ctx)
void takeNodes(const ExplodedNodeSet &S)
ExplodedNode * generateNode(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred, bool MarkAsSink=false)
Generates a node in the ExplodedGraph.
ExplodedNode * generateSink(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred)
Generates a sink in the ExplodedGraph.
ExplodedNodeSet & Frontier
The frontier set - a set of nodes which need to be propagated after the builder dies.
void addNodes(ExplodedNode *N)
ExplodedNode * generateSink(const Stmt *S, ExplodedNode *Pred, ProgramStateRef St, const ProgramPointTag *tag=nullptr, ProgramPoint::Kind K=ProgramPoint::PostStmtKind)
ExplodedNode * generateNode(const Stmt *S, ExplodedNode *Pred, ProgramStateRef St, const ProgramPointTag *tag=nullptr, ProgramPoint::Kind K=ProgramPoint::PostStmtKind)
void addNodes(const ExplodedNodeSet &S)
bool hasGeneratedNodes() const
const ExplodedNodeSet & getResults() const
NodeBuilder(ExplodedNodeSet &DstSet, const NodeBuilderContext &Ctx)
NodeBuilder(const ExplodedNodeSet &SrcSet, ExplodedNodeSet &DstSet, const NodeBuilderContext &Ctx)
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
The JSON file list parser is used to communicate input to InstallAPI.