clang 20.0.0git
CoreEngine.h
Go to the documentation of this file.
1//===- CoreEngine.h - Path-Sensitive Dataflow Engine ------------*- 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 generic engine for intraprocedural, path-sensitive,
10// dataflow analysis via graph reachability.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_COREENGINE_H
15#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_COREENGINE_H
16
17#include "clang/AST/Stmt.h"
19#include "clang/Analysis/CFG.h"
21#include "clang/Basic/LLVM.h"
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/ADT/iterator_range.h"
29#include "llvm/Support/Casting.h"
30#include <cassert>
31#include <memory>
32#include <utility>
33#include <vector>
34
35namespace clang {
36
37class AnalyzerOptions;
38class CXXBindTemporaryExpr;
39class Expr;
40class LabelDecl;
41
42namespace ento {
43
44class FunctionSummariesTy;
45class ExprEngine;
46
47//===----------------------------------------------------------------------===//
48/// CoreEngine - Implements the core logic of the graph-reachability analysis.
49/// It traverses the CFG and generates the ExplodedGraph.
51 friend class CommonNodeBuilder;
53 friend class ExprEngine;
55 friend class NodeBuilder;
56 friend class NodeBuilderContext;
57 friend class SwitchNodeBuilder;
58
59public:
61 std::vector<std::pair<BlockEdge, const ExplodedNode *>>;
62
64 std::vector<std::pair<const CFGBlock *, const ExplodedNode *>>;
65
66private:
67 ExprEngine &ExprEng;
68
69 /// G - The simulation graph. Each node is a (location,state) pair.
70 mutable ExplodedGraph G;
71
72 /// WList - A set of queued nodes that need to be processed by the
73 /// worklist algorithm. It is up to the implementation of WList to decide
74 /// the order that nodes are processed.
75 std::unique_ptr<WorkList> WList;
76 std::unique_ptr<WorkList> CTUWList;
77
78 /// BCounterFactory - A factory object for created BlockCounter objects.
79 /// These are used to record for key nodes in the ExplodedGraph the
80 /// number of times different CFGBlocks have been visited along a path.
81 BlockCounter::Factory BCounterFactory;
82
83 /// The locations where we stopped doing work because we visited a location
84 /// too many times.
85 BlocksExhausted blocksExhausted;
86
87 /// The locations where we stopped because the engine aborted analysis,
88 /// usually because it could not reason about something.
89 BlocksAborted blocksAborted;
90
91 /// The information about functions shared by the whole translation unit.
92 /// (This data is owned by AnalysisConsumer.)
93 FunctionSummariesTy *FunctionSummaries;
94
95 /// Add path tags with some useful data along the path when we see that
96 /// something interesting is happening. This field is the allocator for such
97 /// tags.
98 DataTag::Factory DataTags;
99
100 void setBlockCounter(BlockCounter C);
101
102 void generateNode(const ProgramPoint &Loc,
103 ProgramStateRef State,
104 ExplodedNode *Pred);
105
106 void HandleBlockEdge(const BlockEdge &E, ExplodedNode *Pred);
107 void HandleBlockEntrance(const BlockEntrance &E, ExplodedNode *Pred);
108 void HandleBlockExit(const CFGBlock *B, ExplodedNode *Pred);
109
110 void HandleCallEnter(const CallEnter &CE, ExplodedNode *Pred);
111
112 void HandlePostStmt(const CFGBlock *B, unsigned StmtIdx, ExplodedNode *Pred);
113
114 void HandleBranch(const Stmt *Cond, const Stmt *Term, const CFGBlock *B,
115 ExplodedNode *Pred);
116 void HandleCleanupTemporaryBranch(const CXXBindTemporaryExpr *BTE,
117 const CFGBlock *B, ExplodedNode *Pred);
118
119 /// Handle conditional logic for running static initializers.
120 void HandleStaticInit(const DeclStmt *DS, const CFGBlock *B,
121 ExplodedNode *Pred);
122
123 void HandleVirtualBaseBranch(const CFGBlock *B, ExplodedNode *Pred);
124
125private:
126 ExplodedNode *generateCallExitBeginNode(ExplodedNode *N,
127 const ReturnStmt *RS);
128
129public:
130 /// Construct a CoreEngine object to analyze the provided CFG.
131 CoreEngine(ExprEngine &exprengine,
133 AnalyzerOptions &Opts);
134
135 CoreEngine(const CoreEngine &) = delete;
136 CoreEngine &operator=(const CoreEngine &) = delete;
137
138 /// getGraph - Returns the exploded graph.
139 ExplodedGraph &getGraph() { return G; }
140
141 /// ExecuteWorkList - Run the worklist algorithm for a maximum number of
142 /// steps. Returns true if there is still simulation state on the worklist.
143 bool ExecuteWorkList(const LocationContext *L, unsigned Steps,
144 ProgramStateRef InitState);
145
146 /// Dispatch the work list item based on the given location information.
147 /// Use Pred parameter as the predecessor state.
149 const WorkListUnit& WU);
150
151 // Functions for external checking of whether we have unfinished work
152 bool wasBlockAborted() const { return !blocksAborted.empty(); }
153 bool wasBlocksExhausted() const { return !blocksExhausted.empty(); }
154 bool hasWorkRemaining() const { return wasBlocksExhausted() ||
155 WList->hasWork() ||
156 wasBlockAborted(); }
157
158 /// Inform the CoreEngine that a basic block was aborted because
159 /// it could not be completely analyzed.
160 void addAbortedBlock(const ExplodedNode *node, const CFGBlock *block) {
161 blocksAborted.push_back(std::make_pair(block, node));
162 }
163
164 WorkList *getWorkList() const { return WList.get(); }
165 WorkList *getCTUWorkList() const { return CTUWList.get(); }
166
167 auto exhausted_blocks() const {
168 return llvm::iterator_range(blocksExhausted);
169 }
170
171 auto aborted_blocks() const { return llvm::iterator_range(blocksAborted); }
172
173 /// Enqueue the given set of nodes onto the work list.
175
176 /// Enqueue nodes that were created as a result of processing
177 /// a statement onto the work list.
178 void enqueue(ExplodedNodeSet &Set, const CFGBlock *Block, unsigned Idx);
179
180 /// enqueue the nodes corresponding to the end of function onto the
181 /// end of path / work list.
183
184 /// Enqueue a single node created as a result of statement processing.
185 void enqueueStmtNode(ExplodedNode *N, const CFGBlock *Block, unsigned Idx);
186
187 DataTag::Factory &getDataTags() { return DataTags; }
188};
189
191 const CoreEngine &Eng;
192 const CFGBlock *Block;
193 const LocationContext *LC;
194
195public:
197 const LocationContext *L)
198 : Eng(E), Block(B), LC(L) {
199 assert(B);
200 }
201
204
205 /// Return the CoreEngine associated with this builder.
206 const CoreEngine &getEngine() const { return Eng; }
207
208 /// Return the CFGBlock associated with this builder.
209 const CFGBlock *getBlock() const { return Block; }
210
211 /// Return the location context associated with this builder.
212 const LocationContext *getLocationContext() const { return LC; }
213
214 /// Returns the number of times the current basic block has been
215 /// visited on the exploded graph path.
216 unsigned blockCount() const {
217 return Eng.WList->getBlockCounter().getNumVisited(
218 LC->getStackFrame(),
219 Block->getBlockID());
220 }
221};
222
223/// \class NodeBuilder
224/// This is the simplest builder which generates nodes in the
225/// ExplodedGraph.
226///
227/// The main benefit of the builder is that it automatically tracks the
228/// frontier nodes (or destination set). This is the set of nodes which should
229/// be propagated to the next step / builder. They are the nodes which have been
230/// added to the builder (either as the input node set or as the newly
231/// constructed nodes) but did not have any outgoing transitions added.
233 virtual void anchor();
234
235protected:
237
238 /// Specifies if the builder results have been finalized. For example, if it
239 /// is set to false, autotransitions are yet to be generated.
241
242 bool HasGeneratedNodes = false;
243
244 /// The frontier set - a set of nodes which need to be propagated after
245 /// the builder dies.
247
248 /// Checks if the results are ready.
249 virtual bool checkResults() {
250 return Finalized;
251 }
252
254 for (const auto I : Frontier)
255 if (I->isSink())
256 return false;
257 return true;
258 }
259
260 /// Allow subclasses to finalize results before result_begin() is executed.
261 virtual void finalizeResults() {}
262
264 ProgramStateRef State,
265 ExplodedNode *Pred,
266 bool MarkAsSink = false);
267
268public:
270 const NodeBuilderContext &Ctx, bool F = true)
271 : C(Ctx), Finalized(F), Frontier(DstSet) {
272 Frontier.Add(SrcNode);
273 }
274
276 const NodeBuilderContext &Ctx, bool F = true)
277 : C(Ctx), Finalized(F), Frontier(DstSet) {
278 Frontier.insert(SrcSet);
279 assert(hasNoSinksInFrontier());
280 }
281
282 virtual ~NodeBuilder() = default;
283
284 /// Generates a node in the ExplodedGraph.
286 ProgramStateRef State,
287 ExplodedNode *Pred) {
288 return generateNodeImpl(
289 PP, State, Pred,
290 /*MarkAsSink=*/State->isPosteriorlyOverconstrained());
291 }
292
293 /// Generates a sink in the ExplodedGraph.
294 ///
295 /// When a node is marked as sink, the exploration from the node is stopped -
296 /// the node becomes the last node on the path and certain kinds of bugs are
297 /// suppressed.
299 ProgramStateRef State,
300 ExplodedNode *Pred) {
301 return generateNodeImpl(PP, State, Pred, true);
302 }
303
306 assert(checkResults());
307 return Frontier;
308 }
309
311
312 /// Iterators through the results frontier.
315 assert(checkResults());
316 return Frontier.begin();
317 }
318
321 return Frontier.end();
322 }
323
324 const NodeBuilderContext &getContext() { return C; }
326
327 void takeNodes(const ExplodedNodeSet &S) {
328 for (const auto I : S)
329 Frontier.erase(I);
330 }
331
335};
336
337/// \class NodeBuilderWithSinks
338/// This node builder keeps track of the generated sink nodes.
340 void anchor() override;
341
342protected:
345
346public:
348 const NodeBuilderContext &Ctx, ProgramPoint &L)
349 : NodeBuilder(Pred, DstSet, Ctx), Location(L) {}
350
352 ExplodedNode *Pred,
353 const ProgramPointTag *Tag = nullptr) {
354 const ProgramPoint &LocalLoc = (Tag ? Location.withTag(Tag) : Location);
355 return NodeBuilder::generateNode(LocalLoc, State, Pred);
356 }
357
359 const ProgramPointTag *Tag = nullptr) {
360 const ProgramPoint &LocalLoc = (Tag ? Location.withTag(Tag) : Location);
361 ExplodedNode *N = NodeBuilder::generateSink(LocalLoc, State, Pred);
362 if (N && N->isSink())
363 sinksGenerated.push_back(N);
364 return N;
365 }
366
368 return sinksGenerated;
369 }
370};
371
372/// \class StmtNodeBuilder
373/// This builder class is useful for generating nodes that resulted from
374/// visiting a statement. The main difference from its parent NodeBuilder is
375/// that it creates a statement specific ProgramPoint.
377 NodeBuilder *EnclosingBldr;
378
379public:
380 /// Constructs a StmtNodeBuilder. If the builder is going to process
381 /// nodes currently owned by another builder(with larger scope), use
382 /// Enclosing builder to transfer ownership.
384 const NodeBuilderContext &Ctx,
385 NodeBuilder *Enclosing = nullptr)
386 : NodeBuilder(SrcNode, DstSet, Ctx), EnclosingBldr(Enclosing) {
387 if (EnclosingBldr)
388 EnclosingBldr->takeNodes(SrcNode);
389 }
390
392 const NodeBuilderContext &Ctx,
393 NodeBuilder *Enclosing = nullptr)
394 : NodeBuilder(SrcSet, DstSet, Ctx), EnclosingBldr(Enclosing) {
395 if (EnclosingBldr)
396 for (const auto I : SrcSet)
397 EnclosingBldr->takeNodes(I);
398 }
399
400 ~StmtNodeBuilder() override;
401
404
406 ExplodedNode *Pred,
408 const ProgramPointTag *tag = nullptr,
411 Pred->getLocationContext(), tag);
412 return NodeBuilder::generateNode(L, St, Pred);
413 }
414
416 ExplodedNode *Pred,
418 const ProgramPointTag *tag = nullptr,
421 Pred->getLocationContext(), tag);
422 return NodeBuilder::generateSink(L, St, Pred);
423 }
424};
425
426/// BranchNodeBuilder is responsible for constructing the nodes
427/// corresponding to the two branches of the if statement - true and false.
429 const CFGBlock *DstT;
430 const CFGBlock *DstF;
431
432 bool InFeasibleTrue;
433 bool InFeasibleFalse;
434
435 void anchor() override;
436
437public:
439 const NodeBuilderContext &C,
440 const CFGBlock *dstT, const CFGBlock *dstF)
441 : NodeBuilder(SrcNode, DstSet, C), DstT(dstT), DstF(dstF),
442 InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {
443 // The branch node builder does not generate autotransitions.
444 // If there are no successors it means that both branches are infeasible.
445 takeNodes(SrcNode);
446 }
447
449 const NodeBuilderContext &C,
450 const CFGBlock *dstT, const CFGBlock *dstF)
451 : NodeBuilder(SrcSet, DstSet, C), DstT(dstT), DstF(dstF),
452 InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {
453 takeNodes(SrcSet);
454 }
455
456 ExplodedNode *generateNode(ProgramStateRef State, bool branch,
457 ExplodedNode *Pred);
458
459 const CFGBlock *getTargetBlock(bool branch) const {
460 return branch ? DstT : DstF;
461 }
462
463 void markInfeasible(bool branch) {
464 if (branch)
465 InFeasibleTrue = true;
466 else
467 InFeasibleFalse = true;
468 }
469
470 bool isFeasible(bool branch) {
471 return branch ? !InFeasibleTrue : !InFeasibleFalse;
472 }
473};
474
476 CoreEngine& Eng;
477 const CFGBlock *Src;
478 const CFGBlock &DispatchBlock;
479 const Expr *E;
480 ExplodedNode *Pred;
481
482public:
484 const Expr *e, const CFGBlock *dispatch, CoreEngine* eng)
485 : Eng(*eng), Src(src), DispatchBlock(*dispatch), E(e), Pred(pred) {}
486
487 class iterator {
489
491
493
494 public:
495 // This isn't really a conventional iterator.
496 // We just implement the deref as a no-op for now to make range-based for
497 // loops work.
498 const iterator &operator*() const { return *this; }
499
500 iterator &operator++() { ++I; return *this; }
501 bool operator!=(const iterator &X) const { return I != X.I; }
502
503 const LabelDecl *getLabel() const {
504 return cast<LabelStmt>((*I)->getLabel())->getDecl();
505 }
506
507 const CFGBlock *getBlock() const {
508 return *I;
509 }
510 };
511
512 iterator begin() { return iterator(DispatchBlock.succ_begin()); }
513 iterator end() { return iterator(DispatchBlock.succ_end()); }
514
515 ExplodedNode *generateNode(const iterator &I,
516 ProgramStateRef State,
517 bool isSink = false);
518
519 const Expr *getTarget() const { return E; }
520
521 ProgramStateRef getState() const { return Pred->State; }
522
524 return Pred->getLocationContext();
525 }
526};
527
529 CoreEngine& Eng;
530 const CFGBlock *Src;
531 const Expr *Condition;
532 ExplodedNode *Pred;
533
534public:
536 const Expr *condition, CoreEngine* eng)
537 : Eng(*eng), Src(src), Condition(condition), Pred(pred) {}
538
539 class iterator {
540 friend class SwitchNodeBuilder;
541
543
545
546 public:
547 iterator &operator++() { ++I; return *this; }
548 bool operator!=(const iterator &X) const { return I != X.I; }
549 bool operator==(const iterator &X) const { return I == X.I; }
550
551 const CaseStmt *getCase() const {
552 return cast<CaseStmt>((*I)->getLabel());
553 }
554
555 const CFGBlock *getBlock() const {
556 return *I;
557 }
558 };
559
560 iterator begin() { return iterator(Src->succ_rbegin()+1); }
561 iterator end() { return iterator(Src->succ_rend()); }
562
563 const SwitchStmt *getSwitch() const {
564 return cast<SwitchStmt>(Src->getTerminator());
565 }
566
567 ExplodedNode *generateCaseStmtNode(const iterator &I,
568 ProgramStateRef State);
569
571 bool isSink = false);
572
573 const Expr *getCondition() const { return Condition; }
574
575 ProgramStateRef getState() const { return Pred->State; }
576
578 return Pred->getLocationContext();
579 }
580};
581
582} // namespace ento
583
584} // namespace clang
585
586#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_COREENGINE_H
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Expr * E
const CFGBlock * Block
Definition: HTMLLogger.cpp:153
#define X(type, name)
Definition: Value.h:143
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.
Definition: CFG.h:604
succ_iterator succ_end()
Definition: CFG.h:985
succ_reverse_iterator succ_rend()
Definition: CFG.h:990
succ_reverse_iterator succ_rbegin()
Definition: CFG.h:989
AdjacentBlocks::const_reverse_iterator const_succ_reverse_iterator
Definition: CFG.h:962
CFGTerminator getTerminator() const
Definition: CFG.h:1079
succ_iterator succ_begin()
Definition: CFG.h:984
AdjacentBlocks::const_iterator const_succ_iterator
Definition: CFG.h:960
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1491
Represents a point when we begin processing an inlined call.
Definition: ProgramPoint.h:628
CaseStmt - Represent a case statement.
Definition: Stmt.h:1811
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1502
This represents one expression.
Definition: Expr.h:110
Represents the declaration of a label.
Definition: Decl.h:499
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const StackFrameContext * getStackFrame() const
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
Definition: ProgramPoint.h:38
static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, const LocationContext *LC, const ProgramPointTag *tag)
ProgramPoint withTag(const ProgramPointTag *tag) const
Create a new ProgramPoint object that is the same as the original except for using the specified tag ...
Definition: ProgramPoint.h:129
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3029
Stmt - This represents one statement.
Definition: Stmt.h:84
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2398
An abstract data type used to count the number of times a given block has been visited along a path a...
Definition: BlockCounter.h:29
BranchNodeBuilder is responsible for constructing the nodes corresponding to the two branches of the ...
Definition: CoreEngine.h:428
BranchNodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet, const NodeBuilderContext &C, const CFGBlock *dstT, const CFGBlock *dstF)
Definition: CoreEngine.h:438
void markInfeasible(bool branch)
Definition: CoreEngine.h:463
ExplodedNode * generateNode(ProgramStateRef State, bool branch, ExplodedNode *Pred)
Definition: CoreEngine.cpp:651
bool isFeasible(bool branch)
Definition: CoreEngine.h:470
BranchNodeBuilder(const ExplodedNodeSet &SrcSet, ExplodedNodeSet &DstSet, const NodeBuilderContext &C, const CFGBlock *dstT, const CFGBlock *dstF)
Definition: CoreEngine.h:448
const CFGBlock * getTargetBlock(bool branch) const
Definition: CoreEngine.h:459
CoreEngine - Implements the core logic of the graph-reachability analysis.
Definition: CoreEngine.h:50
void addAbortedBlock(const ExplodedNode *node, const CFGBlock *block)
Inform the CoreEngine that a basic block was aborted because it could not be completely analyzed.
Definition: CoreEngine.h:160
DataTag::Factory & getDataTags()
Definition: CoreEngine.h:187
void enqueueStmtNode(ExplodedNode *N, const CFGBlock *Block, unsigned Idx)
Enqueue a single node created as a result of statement processing.
Definition: CoreEngine.cpp:530
bool wasBlockAborted() const
Definition: CoreEngine.h:152
CoreEngine & operator=(const CoreEngine &)=delete
friend class CommonNodeBuilder
Definition: CoreEngine.h:51
void dispatchWorkItem(ExplodedNode *Pred, ProgramPoint Loc, const WorkListUnit &WU)
Dispatch the work list item based on the given location information.
Definition: CoreEngine.cpp:182
WorkList * getCTUWorkList() const
Definition: CoreEngine.h:165
bool wasBlocksExhausted() const
Definition: CoreEngine.h:153
WorkList * getWorkList() const
Definition: CoreEngine.h:164
std::vector< std::pair< BlockEdge, const ExplodedNode * > > BlocksExhausted
Definition: CoreEngine.h:61
CoreEngine(const CoreEngine &)=delete
std::vector< std::pair< const CFGBlock *, const ExplodedNode * > > BlocksAborted
Definition: CoreEngine.h:64
bool ExecuteWorkList(const LocationContext *L, unsigned Steps, ProgramStateRef InitState)
ExecuteWorkList - Run the worklist algorithm for a maximum number of steps.
Definition: CoreEngine.cpp:88
friend class EndOfFunctionNodeBuilder
Definition: CoreEngine.h:52
auto exhausted_blocks() const
Definition: CoreEngine.h:167
bool hasWorkRemaining() const
Definition: CoreEngine.h:154
ExplodedGraph & getGraph()
getGraph - Returns the exploded graph.
Definition: CoreEngine.h:139
void enqueueEndOfFunction(ExplodedNodeSet &Set, const ReturnStmt *RS)
enqueue the nodes corresponding to the end of function onto the end of path / work list.
Definition: CoreEngine.cpp:605
auto aborted_blocks() const
Definition: CoreEngine.h:171
void enqueue(ExplodedNodeSet &Set)
Enqueue the given set of nodes onto the work list.
Definition: CoreEngine.cpp:594
bool erase(ExplodedNode *N)
void insert(const ExplodedNodeSet &S)
void Add(ExplodedNode *N)
const LocationContext * getLocationContext() const
bool operator!=(const iterator &X) const
Definition: CoreEngine.h:501
const Expr * getTarget() const
Definition: CoreEngine.h:519
const LocationContext * getLocationContext() const
Definition: CoreEngine.h:523
IndirectGotoNodeBuilder(ExplodedNode *pred, const CFGBlock *src, const Expr *e, const CFGBlock *dispatch, CoreEngine *eng)
Definition: CoreEngine.h:483
ProgramStateRef getState() const
Definition: CoreEngine.h:521
ExplodedNode * generateNode(const iterator &I, ProgramStateRef State, bool isSink=false)
Definition: CoreEngine.cpp:665
const CoreEngine & getEngine() const
Return the CoreEngine associated with this builder.
Definition: CoreEngine.h:206
const CFGBlock * getBlock() const
Return the CFGBlock associated with this builder.
Definition: CoreEngine.h:209
NodeBuilderContext(const CoreEngine &E, const CFGBlock *B, const LocationContext *L)
Definition: CoreEngine.h:196
NodeBuilderContext(const CoreEngine &E, const CFGBlock *B, ExplodedNode *N)
Definition: CoreEngine.h:202
const LocationContext * getLocationContext() const
Return the location context associated with this builder.
Definition: CoreEngine.h:212
unsigned blockCount() const
Returns the number of times the current basic block has been visited on the exploded graph path.
Definition: CoreEngine.h:216
This node builder keeps track of the generated sink nodes.
Definition: CoreEngine.h:339
ExplodedNode * generateNode(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
Definition: CoreEngine.h:351
NodeBuilderWithSinks(ExplodedNode *Pred, ExplodedNodeSet &DstSet, const NodeBuilderContext &Ctx, ProgramPoint &L)
Definition: CoreEngine.h:347
ExplodedNode * generateSink(ProgramStateRef State, ExplodedNode *Pred, const ProgramPointTag *Tag=nullptr)
Definition: CoreEngine.h:358
const SmallVectorImpl< ExplodedNode * > & getSinks() const
Definition: CoreEngine.h:367
SmallVector< ExplodedNode *, 2 > sinksGenerated
Definition: CoreEngine.h:343
This is the simplest builder which generates nodes in the ExplodedGraph.
Definition: CoreEngine.h:232
const NodeBuilderContext & C
Definition: CoreEngine.h:236
virtual void finalizeResults()
Allow subclasses to finalize results before result_begin() is executed.
Definition: CoreEngine.h:261
bool Finalized
Specifies if the builder results have been finalized.
Definition: CoreEngine.h:240
virtual ~NodeBuilder()=default
void takeNodes(ExplodedNode *N)
Definition: CoreEngine.h:332
ExplodedNode * generateNode(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred)
Generates a node in the ExplodedGraph.
Definition: CoreEngine.h:285
iterator begin()
Iterators through the results frontier.
Definition: CoreEngine.h:313
ExplodedNodeSet::iterator iterator
Definition: CoreEngine.h:310
void takeNodes(const ExplodedNodeSet &S)
Definition: CoreEngine.h:327
NodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet, const NodeBuilderContext &Ctx, bool F=true)
Definition: CoreEngine.h:269
ExplodedNode * generateSink(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred)
Generates a sink in the ExplodedGraph.
Definition: CoreEngine.h:298
ExplodedNodeSet & Frontier
The frontier set - a set of nodes which need to be propagated after the builder dies.
Definition: CoreEngine.h:246
void addNodes(ExplodedNode *N)
Definition: CoreEngine.h:334
void addNodes(const ExplodedNodeSet &S)
Definition: CoreEngine.h:333
const NodeBuilderContext & getContext()
Definition: CoreEngine.h:324
NodeBuilder(const ExplodedNodeSet &SrcSet, ExplodedNodeSet &DstSet, const NodeBuilderContext &Ctx, bool F=true)
Definition: CoreEngine.h:275
virtual bool checkResults()
Checks if the results are ready.
Definition: CoreEngine.h:249
ExplodedNode * generateNodeImpl(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred, bool MarkAsSink=false)
Definition: CoreEngine.cpp:622
const ExplodedNodeSet & getResults()
Definition: CoreEngine.h:304
This builder class is useful for generating nodes that resulted from visiting a statement.
Definition: CoreEngine.h:376
ExplodedNode * generateNode(const Stmt *S, ExplodedNode *Pred, ProgramStateRef St, const ProgramPointTag *tag=nullptr, ProgramPoint::Kind K=ProgramPoint::PostStmtKind)
Definition: CoreEngine.h:405
ExplodedNode * generateSink(const Stmt *S, ExplodedNode *Pred, ProgramStateRef St, const ProgramPointTag *tag=nullptr, ProgramPoint::Kind K=ProgramPoint::PostStmtKind)
Definition: CoreEngine.h:415
StmtNodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet, const NodeBuilderContext &Ctx, NodeBuilder *Enclosing=nullptr)
Constructs a StmtNodeBuilder.
Definition: CoreEngine.h:383
StmtNodeBuilder(ExplodedNodeSet &SrcSet, ExplodedNodeSet &DstSet, const NodeBuilderContext &Ctx, NodeBuilder *Enclosing=nullptr)
Definition: CoreEngine.h:391
bool operator==(const iterator &X) const
Definition: CoreEngine.h:549
bool operator!=(const iterator &X) const
Definition: CoreEngine.h:548
const CFGBlock * getBlock() const
Definition: CoreEngine.h:555
const CaseStmt * getCase() const
Definition: CoreEngine.h:551
ProgramStateRef getState() const
Definition: CoreEngine.h:575
const Expr * getCondition() const
Definition: CoreEngine.h:573
ExplodedNode * generateDefaultCaseNode(ProgramStateRef State, bool isSink=false)
Definition: CoreEngine.cpp:699
ExplodedNode * generateCaseStmtNode(const iterator &I, ProgramStateRef State)
Definition: CoreEngine.cpp:684
const LocationContext * getLocationContext() const
Definition: CoreEngine.h:577
SwitchNodeBuilder(ExplodedNode *pred, const CFGBlock *src, const Expr *condition, CoreEngine *eng)
Definition: CoreEngine.h:535
const SwitchStmt * getSwitch() const
Definition: CoreEngine.h:563
The JSON file list parser is used to communicate input to InstallAPI.