diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 18:11:16 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 18:11:16 +0000 |
| commit | 59d1ed5b206db2a86b3b5bb851f393c43b568ce2 (patch) | |
| tree | d4426858455f04d0d8c25a2f9eb9ea5582ffe1b6 /contrib/llvm/tools/clang/lib/Analysis/CallGraph.cpp | |
| parent | 91bc56ed825ba56b3cc264aa5c95ab84f86832ab (diff) | |
| parent | 9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 (diff) | |
Notes
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Analysis/CallGraph.cpp')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/Analysis/CallGraph.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/contrib/llvm/tools/clang/lib/Analysis/CallGraph.cpp b/contrib/llvm/tools/clang/lib/Analysis/CallGraph.cpp index 33870158b384..f41a96d30ea5 100644 --- a/contrib/llvm/tools/clang/lib/Analysis/CallGraph.cpp +++ b/contrib/llvm/tools/clang/lib/Analysis/CallGraph.cpp @@ -10,8 +10,6 @@ // This file defines the AST-based CallGraph. // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "CallGraph" - #include "clang/Analysis/CallGraph.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" @@ -22,6 +20,8 @@ using namespace clang; +#define DEBUG_TYPE "CallGraph" + STATISTIC(NumObjCCallEdges, "Number of Objective-C method call edges"); STATISTIC(NumBlockCallEdges, "Number of block call edges"); @@ -49,7 +49,7 @@ public: return Block->getBlockDecl(); } - return 0; + return nullptr; } void addCalledDecl(Decl *D) { @@ -70,7 +70,7 @@ public: Selector Sel = ME->getSelector(); // Find the callee definition within the same translation unit. - Decl *D = 0; + Decl *D = nullptr; if (ME->isInstanceMessage()) D = IDecl->lookupPrivateMethod(Sel); else @@ -95,23 +95,17 @@ void CallGraph::addNodesForBlocks(DeclContext *D) { if (BlockDecl *BD = dyn_cast<BlockDecl>(D)) addNodeForDecl(BD, true); - for (DeclContext::decl_iterator I = D->decls_begin(), E = D->decls_end(); - I!=E; ++I) - if (DeclContext *DC = dyn_cast<DeclContext>(*I)) + for (auto *I : D->decls()) + if (auto *DC = dyn_cast<DeclContext>(I)) addNodesForBlocks(DC); } CallGraph::CallGraph() { - Root = getOrInsertNode(0); + Root = getOrInsertNode(nullptr); } CallGraph::~CallGraph() { - if (!FunctionMap.empty()) { - for (FunctionMapTy::iterator I = FunctionMap.begin(), E = FunctionMap.end(); - I != E; ++I) - delete I->second; - FunctionMap.clear(); - } + llvm::DeleteContainerSeconds(FunctionMap); } bool CallGraph::includeInGraph(const Decl *D) { @@ -153,7 +147,7 @@ void CallGraph::addNodeForDecl(Decl* D, bool IsGlobal) { CallGraphNode *CallGraph::getNode(const Decl *F) const { FunctionMapTy::const_iterator I = FunctionMap.find(F); - if (I == FunctionMap.end()) return 0; + if (I == FunctionMap.end()) return nullptr; return I->second; } @@ -164,7 +158,7 @@ CallGraphNode *CallGraph::getOrInsertNode(Decl *F) { Node = new CallGraphNode(F); // Make Root node a parent of all functions to make sure all are reachable. - if (F != 0) + if (F) Root->addCallee(Node, this); return Node; } |
