//===- CallGraph.h - AST-based Call graph -----------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file declares the AST-based CallGraph. // // A call graph for functions whose definitions/bodies are available in the // current translation unit. The graph has a "virtual" root node that contains // edges to all externally available functions. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_ANALYSIS_CALLGRAPH_H #define LLVM_CLANG_ANALYSIS_CALLGRAPH_H #include "clang/AST/Decl.h" #include "clang/AST/RecursiveASTVisitor.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator_range.h" #include <memory> namespace clang { class CallGraphNode; class Decl; class DeclContext; class Stmt; /// The AST-based call graph. /// /// The call graph extends itself with the given declarations by implementing /// the recursive AST visitor, which constructs the graph by visiting the given /// declarations. class CallGraph : public RecursiveASTVisitor<CallGraph> { … }; class CallGraphNode { … }; // NOTE: we are comparing based on the callee only. So different call records // (with different call expressions) to the same callee will compare equal! inline bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS) { … } } // namespace clang namespace llvm { // Specialize DenseMapInfo for clang::CallGraphNode::CallRecord. template <> struct DenseMapInfo<clang::CallGraphNode::CallRecord> { … }; // Graph traits for iteration, viewing. template <> struct GraphTraits<clang::CallGraphNode*> { … }; template <> struct GraphTraits<const clang::CallGraphNode*> { … }; template <> struct GraphTraits<clang::CallGraph*> : public GraphTraits<clang::CallGraphNode*> { … }; template <> struct GraphTraits<const clang::CallGraph*> : public GraphTraits<const clang::CallGraphNode*> { … }; } // namespace llvm #endif // LLVM_CLANG_ANALYSIS_CALLGRAPH_H