diff options
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 3387015..f41a96d 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; } |