20 #include "llvm/ADT/DenseSet.h" 21 #include "llvm/ADT/SmallVector.h" 22 #include "llvm/ADT/Statistic.h" 24 using namespace clang;
49 : NumNodes(0), ReclaimNodeInterval(0) {}
60 return isa<DeclRefExpr>(Ex) ||
61 isa<MemberExpr>(Ex) ||
62 isa<ObjCIvarRefExpr>(Ex);
65 bool ExplodedGraph::shouldCollect(
const ExplodedNode *node) {
112 return !progPoint.
getTag();
125 if (state->store != pred_state->store || state->GDM != pred_state->GDM ||
170 pred->replaceSuccessor(succ);
171 succ->replacePredecessor(pred);
173 Nodes.RemoveNode(node);
175 node->~ExplodedNode();
193 if (shouldCollect(node))
214 typedef llvm::PointerUnion<ExplodedNode *, ExplodedNodeVector *>
GroupStorage;
219 V->Succs.addNode(
this, G);
221 if (NodeAuditor) NodeAuditor->
AddEdge(V,
this);
225 void ExplodedNode::NodeGroup::replaceNode(
ExplodedNode *node) {
238 if (Storage.isNull()) {
263 unsigned ExplodedNode::NodeGroup::size()
const {
268 if (Storage.isNull())
275 ExplodedNode *
const *ExplodedNode::NodeGroup::begin()
const {
280 if (Storage.isNull())
284 return Storage.getAddrOfPtr1();
287 ExplodedNode *
const *ExplodedNode::NodeGroup::end()
const {
292 if (Storage.isNull())
296 return Storage.getAddrOfPtr1() + 1;
304 llvm::FoldingSetNodeID profile;
305 void *InsertPos =
nullptr;
308 NodeTy* V =
Nodes.FindNodeOrInsertPos(profile, InsertPos);
320 new (V)
NodeTy(L, State, IsSink);
326 Nodes.InsertNode(V, InsertPos);
329 if (IsNew) *IsNew =
true;
332 if (IsNew) *IsNew =
false;
341 new (V)
NodeTy(L, State, IsSink);
345 std::unique_ptr<ExplodedGraph>
358 Pass2Ty &Pass2 = ForwardMap ? *ForwardMap : Pass2Scratch;
370 while (!WL1.empty()) {
374 if (!Pass1.insert(N).second)
378 if (N->Preds.empty()) {
384 WL1.append(N->Preds.begin(), N->Preds.end());
395 while (!WL2.empty()) {
399 if (Pass2.find(N) != Pass2.end())
408 if (InverseMap) (*InverseMap)[NewN] = N;
411 if (N->Preds.empty())
421 Pass2Ty::iterator PI = Pass2.find(*I);
422 if (PI == Pass2.end())
434 Pass2Ty::iterator PI = Pass2.find(*I);
435 if (PI != Pass2.end()) {
436 const_cast<ExplodedNode *
>(PI->second)->addPredecessor(NewN, *G);
unsigned ReclaimCounter
Counter to determine when to reclaim nodes.
ExplodedNode *const * succ_iterator
NodeVector FreeNodes
A list of nodes that can be reused.
unsigned NumNodes
NumNodes - The number of nodes in the graph.
Represents a point when we begin processing an inlined call.
Represents a point after we ran remove dead bindings BEFORE processing the given statement.
Represents a program point just before an implicit call event.
const ProgramStateRef & getState() const
bool isConsumedExpr(Expr *E) const
NodeVector ChangedNodes
A list of recently allocated nodes that can potentially be recycled.
BumpVector< ExplodedNode * > ExplodedNodeVector
succ_iterator succ_begin()
Represents a program point after a store evaluation.
std::unique_ptr< ExplodedGraph > trim(ArrayRef< const NodeTy *> Nodes, InterExplodedGraphMap *ForwardMap=nullptr, InterExplodedGraphMap *InverseMap=nullptr) const
Creates a trimmed version of the graph that only contains paths leading to the given nodes...
void addPredecessor(ExplodedNode *V, ExplodedGraph &G)
addPredeccessor - Adds a predecessor to the current node, and in tandem add this node as a successor ...
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
unsigned succ_size() const
const LocationContext * getLocationContext() const
std::unique_ptr< ExplodedGraph > MakeEmptyGraph() const
unsigned pred_size() const
ExplodedNode * createUncachedNode(const ProgramPoint &L, ProgramStateRef State, bool IsSink=false)
Create a node for a (Location, State) pair, but don't store it for deduplication later.
llvm::DenseMap< const ExplodedNode *, const ExplodedNode * > InterExplodedGraphMap
Expr - This represents one expression.
static ExplodedNode::Auditor * NodeAuditor
static void Profile(llvm::FoldingSetNodeID &ID, const ProgramPoint &Loc, const ProgramStateRef &state, bool IsSink)
ExplodedNode * getNode(const ProgramPoint &L, ProgramStateRef State, bool IsSink=false, bool *IsNew=nullptr)
Retrieve the node associated with a (Location,State) pair, where the 'Location' is a ProgramPoint in ...
ParentMap & getParentMap() const
ExplodedNode *const * pred_iterator
unsigned ReclaimNodeInterval
Determines how often nodes are reclaimed.
T castAs() const
Convert to the specified ProgramPoint type, asserting that this ProgramPoint is of the desired type...
static bool isCallStmt(const Stmt *S)
Returns true if this is a statement is a function or method call of some kind.
llvm::FoldingSet< ExplodedNode > Nodes
Nodes - The nodes in the graph.
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
void push_back(const_reference Elt, BumpVectorContext &C)
Dataflow Directional Tag Classes.
BumpVectorContext & getNodeAllocator()
virtual void AddEdge(ExplodedNode *Src, ExplodedNode *Dst)=0
void reclaimRecentlyAllocatedNodes()
Reclaim "uninteresting" nodes created since the last time this method was called. ...
const ProgramPointTag * getTag() const
static void SetAuditor(Auditor *A)
const LocationContext * getLocationContext() const
pred_iterator pred_begin()
llvm::BumpPtrAllocator & getAllocator()
Optional< T > getAs() const
Convert to the specified ProgramPoint type, returning None if this ProgramPoint is not of the desired...
static bool isInterestingLValueExpr(const Expr *Ex)
Returns true if nodes for the given expression kind are always kept around.
llvm::PointerUnion< ExplodedNode *, ExplodedNodeVector * > GroupStorage