diff options
Diffstat (limited to 'lib/StaticAnalyzer/Core/ExplodedGraph.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/ExplodedGraph.cpp | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp index 3bc8e09333b9..ece103d9d09a 100644 --- a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp +++ b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp @@ -1,4 +1,4 @@ -//=-- ExplodedGraph.cpp - Local, Path-Sens. "Exploded Graph" -*- C++ -*------=// +//===- ExplodedGraph.cpp - Local, Path-Sens. "Exploded Graph" -------------===// // // The LLVM Compiler Infrastructure // @@ -13,13 +13,24 @@ //===----------------------------------------------------------------------===// #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" +#include "clang/AST/Expr.h" +#include "clang/AST/ExprObjC.h" #include "clang/AST/ParentMap.h" #include "clang/AST/Stmt.h" +#include "clang/Analysis/ProgramPoint.h" +#include "clang/Analysis/Support/BumpVector.h" +#include "clang/Basic/LLVM.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/Statistic.h" +#include "llvm/Support/Casting.h" +#include <cassert> +#include <memory> using namespace clang; using namespace ento; @@ -29,7 +40,7 @@ using namespace ento; //===----------------------------------------------------------------------===// // An out of line virtual method to provide a home for the class vtable. -ExplodedNode::Auditor::~Auditor() {} +ExplodedNode::Auditor::~Auditor() = default; #ifndef NDEBUG static ExplodedNode::Auditor* NodeAuditor = nullptr; @@ -45,10 +56,9 @@ void ExplodedNode::SetAuditor(ExplodedNode::Auditor* A) { // Cleanup. //===----------------------------------------------------------------------===// -ExplodedGraph::ExplodedGraph() - : NumNodes(0), ReclaimNodeInterval(0) {} +ExplodedGraph::ExplodedGraph() = default; -ExplodedGraph::~ExplodedGraph() {} +ExplodedGraph::~ExplodedGraph() = default; //===----------------------------------------------------------------------===// // Node reclamation. @@ -187,12 +197,9 @@ void ExplodedGraph::reclaimRecentlyAllocatedNodes() { return; ReclaimCounter = ReclaimNodeInterval; - for (NodeVector::iterator it = ChangedNodes.begin(), et = ChangedNodes.end(); - it != et; ++it) { - ExplodedNode *node = *it; + for (const auto node : ChangedNodes) if (shouldCollect(node)) collectNode(node); - } ChangedNodes.clear(); } @@ -210,11 +217,11 @@ void ExplodedGraph::reclaimRecentlyAllocatedNodes() { // 2. The group is empty, in which case the storage value is null. // 3. The group contains a single node. // 4. The group contains more than one node. -typedef BumpVector<ExplodedNode *> ExplodedNodeVector; -typedef llvm::PointerUnion<ExplodedNode *, ExplodedNodeVector *> GroupStorage; +using ExplodedNodeVector = BumpVector<ExplodedNode *>; +using GroupStorage = llvm::PointerUnion<ExplodedNode *, ExplodedNodeVector *>; void ExplodedNode::addPredecessor(ExplodedNode *V, ExplodedGraph &G) { - assert (!V->isSink()); + assert(!V->isSink()); Preds.addNode(V, G); V->Succs.addNode(this, G); #ifndef NDEBUG @@ -346,25 +353,22 @@ std::unique_ptr<ExplodedGraph> ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks, InterExplodedGraphMap *ForwardMap, InterExplodedGraphMap *InverseMap) const { - if (Nodes.empty()) return nullptr; - typedef llvm::DenseSet<const ExplodedNode*> Pass1Ty; + using Pass1Ty = llvm::DenseSet<const ExplodedNode *>; Pass1Ty Pass1; - typedef InterExplodedGraphMap Pass2Ty; + using Pass2Ty = InterExplodedGraphMap; InterExplodedGraphMap Pass2Scratch; Pass2Ty &Pass2 = ForwardMap ? *ForwardMap : Pass2Scratch; SmallVector<const ExplodedNode*, 10> WL1, WL2; // ===- Pass 1 (reverse DFS) -=== - for (ArrayRef<const NodeTy *>::iterator I = Sinks.begin(), E = Sinks.end(); - I != E; ++I) { - if (*I) - WL1.push_back(*I); - } + for (const auto Sink : Sinks) + if (Sink) + WL1.push_back(Sink); // Process the first worklist until it is empty. while (!WL1.empty()) { @@ -445,4 +449,3 @@ ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks, return G; } - |