|
clang
5.0.0
|
The AST-based call graph. More...
#include "clang/Analysis/CallGraph.h"
Public Types | |
| typedef FunctionMapTy::iterator | iterator |
| Iterators through all the elements in the graph. More... | |
| typedef FunctionMapTy::const_iterator | const_iterator |
| typedef llvm::SetVector < CallGraphNode * >::iterator | nodes_iterator |
| Iterators through all the nodes of the graph that have no parent. More... | |
| typedef llvm::SetVector < CallGraphNode * > ::const_iterator | const_nodes_iterator |
Public Types inherited from clang::RecursiveASTVisitor< CallGraph > | |
| typedef SmallVectorImpl < llvm::PointerIntPair< Stmt *, 1, bool > > | DataRecursionQueue |
| A queue used for performing data recursion over statements. More... | |
Public Member Functions | |
| CallGraph () | |
| ~CallGraph () | |
| void | addToCallGraph (Decl *D) |
| Populate the call graph with the functions in the given declaration. More... | |
| CallGraphNode * | getNode (const Decl *) const |
| Lookup the node for the given declaration. More... | |
| CallGraphNode * | getOrInsertNode (Decl *) |
| Lookup the node for the given declaration. More... | |
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| unsigned | size () const |
| Get the number of nodes in the graph. More... | |
| CallGraphNode * | getRoot () const |
| \ brief Get the virtual root of the graph, all the functions available externally are represented as callees of the node. More... | |
| void | print (raw_ostream &os) const |
| void | dump () const |
| void | viewGraph () const |
| void | addNodesForBlocks (DeclContext *D) |
| bool | VisitFunctionDecl (FunctionDecl *FD) |
| Part of recursive declaration visitation. More... | |
| bool | VisitObjCMethodDecl (ObjCMethodDecl *MD) |
| Part of recursive declaration visitation. More... | |
| bool | TraverseStmt (Stmt *S) |
| bool | shouldWalkTypesOfTypeLocs () const |
Public Member Functions inherited from clang::RecursiveASTVisitor< CallGraph > | |
| CallGraph & | getDerived () |
| Return a reference to the derived class. More... | |
| bool | shouldVisitTemplateInstantiations () const |
| Return whether this visitor should recurse into template instantiations. More... | |
| bool | shouldWalkTypesOfTypeLocs () const |
| Return whether this visitor should recurse into the types of TypeLocs. More... | |
| bool | shouldVisitImplicitCode () const |
| Return whether this visitor should recurse into implicit code, e.g., implicit constructors and destructors. More... | |
| bool | shouldTraversePostOrder () const |
| Return whether this visitor should traverse post-order. More... | |
| bool | TraverseStmt (Stmt *S, DataRecursionQueue *Queue=nullptr) |
| Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dynamic type. More... | |
| bool | dataTraverseStmtPre (Stmt *S) |
| Invoked before visiting a statement or expression via data recursion. More... | |
| bool | dataTraverseStmtPost (Stmt *S) |
| Invoked after visiting a statement or expression via data recursion. More... | |
| bool | TraverseType (QualType T) |
| Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() property. More... | |
| bool | TraverseTypeLoc (TypeLoc TL) |
| Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument type's getTypeClass() property. More... | |
| bool | TraverseAttr (Attr *At) |
| Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic type. More... | |
| bool | TraverseDecl (Decl *D) |
| Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic type. More... | |
| bool | TraverseNestedNameSpecifier (NestedNameSpecifier *NNS) |
| Recursively visit a C++ nested-name-specifier. More... | |
| bool | TraverseNestedNameSpecifierLoc (NestedNameSpecifierLoc NNS) |
| Recursively visit a C++ nested-name-specifier with location information. More... | |
| bool | TraverseDeclarationNameInfo (DeclarationNameInfo NameInfo) |
| Recursively visit a name with its location information. More... | |
| bool | TraverseTemplateName (TemplateName Template) |
| Recursively visit a template name and dispatch to the appropriate method. More... | |
| bool | TraverseTemplateArgument (const TemplateArgument &Arg) |
| Recursively visit a template argument and dispatch to the appropriate method for the argument type. More... | |
| bool | TraverseTemplateArgumentLoc (const TemplateArgumentLoc &ArgLoc) |
| Recursively visit a template argument location and dispatch to the appropriate method for the argument type. More... | |
| bool | TraverseTemplateArguments (const TemplateArgument *Args, unsigned NumArgs) |
| Recursively visit a set of template arguments. More... | |
| bool | TraverseConstructorInitializer (CXXCtorInitializer *Init) |
| Recursively visit a constructor initializer. More... | |
| bool | TraverseLambdaCapture (LambdaExpr *LE, const LambdaCapture *C, Expr *Init) |
| Recursively visit a lambda capture. More... | |
| bool | TraverseLambdaBody (LambdaExpr *LE, DataRecursionQueue *Queue=nullptr) |
| Recursively visit the body of a lambda expression. More... | |
| bool | TraverseSynOrSemInitListExpr (InitListExpr *S, DataRecursionQueue *Queue=nullptr) |
| Recursively visit the syntactic or semantic form of an initialization list. More... | |
| bool | VisitAttr (Attr *A) |
| bool | WalkUpFromStmt (Stmt *S) |
| bool | VisitStmt (Stmt *S) |
| bool | WalkUpFromType (Type *T) |
| bool | VisitType (Type *T) |
| bool | WalkUpFromTypeLoc (TypeLoc TL) |
| bool | VisitTypeLoc (TypeLoc TL) |
| bool | WalkUpFromQualifiedTypeLoc (QualifiedTypeLoc TL) |
| bool | VisitQualifiedTypeLoc (QualifiedTypeLoc TL) |
| bool | WalkUpFromUnqualTypeLoc (UnqualTypeLoc TL) |
| bool | VisitUnqualTypeLoc (UnqualTypeLoc TL) |
| bool | WalkUpFromDecl (Decl *D) |
| bool | VisitDecl (Decl *D) |
Static Public Member Functions | |
| static bool | includeInGraph (const Decl *D) |
| Determine if a declaration should be included in the graph. More... | |
Friends | |
| class | CallGraphNode |
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.
Definition at line 34 of file CallGraph.h.
| typedef FunctionMapTy::const_iterator clang::CallGraph::const_iterator |
Definition at line 71 of file CallGraph.h.
| typedef llvm::SetVector<CallGraphNode *>::const_iterator clang::CallGraph::const_nodes_iterator |
Definition at line 88 of file CallGraph.h.
| typedef FunctionMapTy::iterator clang::CallGraph::iterator |
Iterators through all the elements in the graph.
Note, this gives non-deterministic order.
Definition at line 70 of file CallGraph.h.
| typedef llvm::SetVector<CallGraphNode *>::iterator clang::CallGraph::nodes_iterator |
Iterators through all the nodes of the graph that have no parent.
These are the unreachable nodes, which are either unused or are due to us failing to add a call edge due to the analysis imprecision.
Definition at line 87 of file CallGraph.h.
| CallGraph::CallGraph | ( | ) |
Definition at line 104 of file CallGraph.cpp.
References getOrInsertNode().
| CallGraph::~CallGraph | ( | ) |
Definition at line 108 of file CallGraph.cpp.
| void CallGraph::addNodesForBlocks | ( | DeclContext * | D | ) |
Definition at line 95 of file CallGraph.cpp.
References clang::DeclContext::decls(), and I.
Referenced by VisitFunctionDecl(), and VisitObjCMethodDecl().
|
inline |
Populate the call graph with the functions in the given declaration.
Recursively walks the declaration to find all the dependent Decls as well.
Definition at line 54 of file CallGraph.h.
References clang::RecursiveASTVisitor< CallGraph >::TraverseDecl().
|
inline |
Definition at line 72 of file CallGraph.h.
Referenced by llvm::GraphTraits< clang::CallGraph * >::nodes_begin(), and llvm::GraphTraits< const clang::CallGraph * >::nodes_begin().
|
inline |
Definition at line 74 of file CallGraph.h.
| LLVM_DUMP_METHOD void CallGraph::dump | ( | ) | const |
Definition at line 190 of file CallGraph.cpp.
References print().
|
inline |
Definition at line 73 of file CallGraph.h.
Referenced by llvm::GraphTraits< clang::CallGraph * >::nodes_end(), and llvm::GraphTraits< const clang::CallGraph * >::nodes_end().
|
inline |
Definition at line 75 of file CallGraph.h.
| CallGraphNode * CallGraph::getNode | ( | const Decl * | F | ) | const |
Lookup the node for the given declaration.
Definition at line 141 of file CallGraph.cpp.
References I.
| CallGraphNode * CallGraph::getOrInsertNode | ( | Decl * | F | ) |
Lookup the node for the given declaration.
If none found, insert one into the graph.
Definition at line 147 of file CallGraph.cpp.
References clang::CallGraphNode::addCallee(), and clang::Decl::getCanonicalDecl().
Referenced by CallGraph().
|
inline |
\ brief Get the virtual root of the graph, all the functions available externally are represented as callees of the node.
Definition at line 82 of file CallGraph.h.
Referenced by llvm::GraphTraits< clang::CallGraph * >::getEntryNode(), llvm::GraphTraits< const clang::CallGraph * >::getEntryNode(), and llvm::DOTGraphTraits< const CallGraph * >::getNodeLabel().
Determine if a declaration should be included in the graph.
Definition at line 110 of file CallGraph.cpp.
References clang::IdentifierInfo::getName(), and clang::Decl::hasBody().
Referenced by VisitFunctionDecl(), and VisitObjCMethodDecl().
| void CallGraph::print | ( | raw_ostream & | os | ) | const |
Definition at line 162 of file CallGraph.cpp.
References clang::CallGraphNode::begin(), E, clang::CallGraphNode::end(), I, and clang::CallGraphNode::print().
Referenced by dump().
|
inline |
Definition at line 124 of file CallGraph.h.
|
inline |
Get the number of nodes in the graph.
Definition at line 78 of file CallGraph.h.
Referenced by llvm::GraphTraits< clang::CallGraph * >::size(), and llvm::GraphTraits< const clang::CallGraph * >::size().
Definition at line 122 of file CallGraph.h.
| void CallGraph::viewGraph | ( | ) | const |
Definition at line 194 of file CallGraph.cpp.
|
inline |
Part of recursive declaration visitation.
We recursively visit all the declarations to collect the root functions.
Definition at line 98 of file CallGraph.h.
References addNodesForBlocks(), includeInGraph(), clang::FunctionDecl::isGlobal(), and clang::FunctionDecl::isThisDeclarationADefinition().
|
inline |
Part of recursive declaration visitation.
Definition at line 113 of file CallGraph.h.
References addNodesForBlocks(), and includeInGraph().
|
friend |
Definition at line 35 of file CallGraph.h.
1.8.6