Index: clang/include/clang/Analysis/CallGraph.h =================================================================== --- clang/include/clang/Analysis/CallGraph.h +++ clang/include/clang/Analysis/CallGraph.h @@ -34,7 +34,8 @@ class CallGraph : public RecursiveASTVisitor { friend class CallGraphNode; - typedef llvm::DenseMap FunctionMapTy; + typedef llvm::DenseMap> + FunctionMapTy; /// FunctionMap owns all CallGraphNodes. FunctionMapTy FunctionMap; @@ -198,9 +199,11 @@ static NodeType *getEntryNode(clang::CallGraph *CGN) { return CGN->getRoot(); // Start at the external node! } - typedef std::pair PairTy; - static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; } + static clang::CallGraphNode * + CGGetValue(decltype(*std::declval()) &P) { + return P.second.get(); + } // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator @@ -223,9 +226,11 @@ static NodeType *getEntryNode(const clang::CallGraph *CGN) { return CGN->getRoot(); } - typedef std::pair PairTy; - static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; } + static clang::CallGraphNode * + CGGetValue(decltype(*std::declval()) &P) { + return P.second.get(); + } // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iteratorsecond; + return I->second.get(); } CallGraphNode *CallGraph::getOrInsertNode(Decl *F) { if (F && !isa(F)) F = F->getCanonicalDecl(); - CallGraphNode *&Node = FunctionMap[F]; + std::unique_ptr &Node = FunctionMap[F]; if (Node) - return Node; + return Node.get(); - Node = new CallGraphNode(F); + Node = llvm::make_unique(F); // Make Root node a parent of all functions to make sure all are reachable. if (F) - Root->addCallee(Node, this); - return Node; + Root->addCallee(Node.get(), this); + return Node.get(); } void CallGraph::print(raw_ostream &OS) const {