17 #ifndef LLVM_CLANG_ANALYSIS_CALLGRAPH_H
18 #define LLVM_CLANG_ANALYSIS_CALLGRAPH_H
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/GraphTraits.h"
24 #include "llvm/ADT/SetVector.h"
37 typedef llvm::DenseMap<const Decl *, std::unique_ptr<CallGraphNode>>
41 FunctionMapTy FunctionMap;
78 unsigned size()
const {
return FunctionMap.size(); }
90 void print(raw_ostream &os)
const;
116 addNodeForDecl(MD,
true);
128 void addNodeForDecl(
Decl *D,
bool IsGlobal);
157 inline bool empty()
const {
return CalledFunctions.empty(); }
158 inline unsigned size()
const {
return CalledFunctions.size(); }
161 CalledFunctions.push_back(N);
166 void print(raw_ostream &os)
const;
174 template <>
struct GraphTraits<clang::CallGraphNode*> {
186 template <>
struct GraphTraits<const clang::CallGraphNode*> {
196 template <>
struct GraphTraits<clang::CallGraph*>
197 :
public GraphTraits<clang::CallGraphNode*> {
205 return P.second.get();
209 typedef mapped_iterator<clang::CallGraph::iterator, decltype(&CGGetValue)>
224 template <>
struct GraphTraits<const clang::CallGraph*> :
225 public GraphTraits<const clang::CallGraphNode*> {
232 return P.second.get();
237 decltype(&CGGetValue)>
The AST-based call graph.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Stmt - This represents one statement.
Decl - This represents one declaration (or definition), e.g.
clang::CallGraphNode NodeType
ObjCMethodDecl - Represents an instance or class method declaration.
CallGraphNode * getOrInsertNode(Decl *)
Lookup the node for the given declaration.
static ChildIteratorType child_end(NodeType *N)
void addCallee(CallGraphNode *N)
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...
static unsigned size(const clang::CallGraph *CG)
bool shouldWalkTypesOfTypeLocs() const
static NodeType * getEntryNode(const clang::CallGraph *CGN)
NodeType::const_iterator ChildIteratorType
static nodes_iterator nodes_begin(clang::CallGraph *CG)
const_iterator begin() const
llvm::SetVector< CallGraphNode * >::iterator nodes_iterator
Iterators through all the nodes of the graph that have no parent.
unsigned size() const
Get the number of nodes in the graph.
void addNodesForBlocks(DeclContext *D)
CallGraphNode * CallRecord
mapped_iterator< clang::CallGraph::const_iterator, decltype(&CGGetValue)> nodes_iterator
const_iterator end() const
static NodeType * getEntryNode(const clang::CallGraphNode *CGN)
clang::CallGraphNode * NodeRef
static nodes_iterator nodes_begin(const clang::CallGraph *CG)
A class that does preordor or postorder depth-first traversal on the entire Clang AST and visits each...
CallGraphNode * getRoot() const
\ brief Get the virtual root of the graph, all the functions available externally are represented as ...
void print(raw_ostream &os) const
SmallVectorImpl< CallRecord >::const_iterator const_iterator
NodeType::iterator ChildIteratorType
bool isGlobal() const
Determines whether this is a global function.
CallGraphNode * getNode(const Decl *) const
Lookup the node for the given declaration.
mapped_iterator< clang::CallGraph::iterator, decltype(&CGGetValue)> nodes_iterator
static clang::CallGraphNode * CGGetValue(clang::CallGraph::const_iterator::value_type &P)
static ChildIteratorType child_end(NodeType *N)
static ChildIteratorType child_begin(NodeType *N)
bool VisitFunctionDecl(FunctionDecl *FD)
Part of recursive declaration visitation.
const clang::CallGraphNode NodeType
static nodes_iterator nodes_end(clang::CallGraph *CG)
FunctionMapTy::iterator iterator
Iterators through all the elements in the graph.
bool TraverseStmt(Stmt *S)
static ChildIteratorType child_begin(NodeType *N)
static bool includeInGraph(const Decl *D)
Determine if a declaration should be included in the graph.
static nodes_iterator nodes_end(const clang::CallGraph *CG)
llvm::SetVector< CallGraphNode * >::const_iterator const_nodes_iterator
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static NodeType * getEntryNode(clang::CallGraphNode *CGN)
const_iterator end() const
void print(raw_ostream &os) const
static NodeType * getEntryNode(clang::CallGraph *CGN)
iterator begin()
Iterators through all the callees/children of the node.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
static clang::CallGraphNode * CGGetValue(clang::CallGraph::const_iterator::value_type &P)
static unsigned size(clang::CallGraph *CG)
SmallVectorImpl< CallRecord >::iterator iterator
void addToCallGraph(Decl *D)
Populate the call graph with the functions in the given declaration.
const_iterator begin() const
bool VisitObjCMethodDecl(ObjCMethodDecl *MD)
Part of recursive declaration visitation.
FunctionMapTy::const_iterator const_iterator
const clang::CallGraphNode * NodeRef