DeclResolver
Records, orders and finds the dependencies of Decls (TypeDecls or FunctionDecls)
#include <DeclResolver.h>
Inherited by FunctionDeclResolver, TypeDeclResolver
Public Functions
Name | |
---|---|
virtual | ~DeclResolver() =0 |
void | addDecl(clang::Decl * D) Records a Decl and automatically adds all Decls that this Decl depends on. |
void | orderAndAddFragments(TargetCode & TC) Creates a TargetCodeFragment for each recorded Decl and adds them to the TargetCode object in the correct order. |
Protected Functions
Name | |
---|---|
virtual void | runOwnVisitor(clang::Decl * D, std::function< void(clang::Decl *Dep)> Fn) =0 With this function, the resolver runs a visitor on the declaration added to find and add all declarations that the added declaration depends on and adds them to the resolver. |
virtual void | findDependDecls(clang::Decl * D, std::unordered_set< clang::Decl * > & UnresolvedDecls) This function uses a visitor to find references to other declarations in the declaration being added. |
Private Functions
Name | |
---|---|
void | topoSort(std::stack< clang::Decl * > & q) This functions does a topological sorting on the dependency graph of all Decls recorded into this object by calling addDecl. |
void | topoSortUtil(std::stack< clang::Decl * > & q, std::map< clang::Decl *, bool > & visited, clang::Decl * D) Helper function for topoSort, to do an recursive DFS. |
Private Attributes
Name | |
---|---|
DeclMap | AllDecls Records all declarations added to the resolver. |
std::set< clang::Decl * > | NonDependentDecls All declarations which do not depend on other declarations. |
std::set< std::string > | RequiredSystemHeaders When a declaration is inside a system header, that header is recorded here instead of the declaratoin. |
Public Functions Documentation
function ~DeclResolver
1 |
|
function addDecl
1 2 3 |
|
Records a Decl and automatically adds all Decls that this Decl depends on.
Parameters:
- D the Decl to be added to the resolver.
function orderAndAddFragments
1 2 3 |
|
Creates a TargetCodeFragment for each recorded Decl and adds them to the TargetCode object in the correct order.
Parameters:
- TC the TargetCode object, the fragments will be added to.
Protected Functions Documentation
function runOwnVisitor
1 2 3 4 |
|
With this function, the resolver runs a visitor on the declaration added to find and add all declarations that the added declaration depends on and adds them to the resolver.
Reimplemented by: TypeDeclResolver::runOwnVisitor, FunctionDeclResolver::runOwnVisitor
function findDependDecls
1 2 3 4 |
|
This function uses a visitor to find references to other declarations in the declaration being added.
Parameters:
- D the declaration that was added via addDecl.
- UnresolvedDecls a set of declarations which D depends on and which are currently unresolved.
Reimplemented by: FunctionDeclResolver::findDependDecls
If the declaration being added references other declarations outside the standard library, we need to add those declaration to the target code too.
Private Functions Documentation
function topoSort
1 2 3 |
|
This functions does a topological sorting on the dependency graph of all Decls recorded into this object by calling addDecl.
Parameters:
- q an queue where the ordered Decls are save to.
This method uses an DFS approach to be able to deal with possible cycles.
function topoSortUtil
1 2 3 4 5 |
|
Helper function for topoSort, to do an recursive DFS.
Private Attributes Documentation
variable AllDecls
1 |
|
Records all declarations added to the resolver.
variable NonDependentDecls
1 |
|
All declarations which do not depend on other declarations.
variable RequiredSystemHeaders
1 |
|
When a declaration is inside a system header, that header is recorded here instead of the declaratoin.