systemc-clang 2.0.0
Parsing SystemC constructs
|
Class InstanceMatcher. More...
#include <InstanceMatcher.h>
Public Types | |
typedef std::tuple< std::string, clang::Decl *, ModuleInstanceType > | InstanceDeclType |
typedef std::vector< InstanceDeclType > | InstanceDeclarationsType |
typedef std::pair< clang::Decl *, ModuleInstanceType > | ModuleInstanceTuple |
typedef std::map< clang::Decl *, ModuleInstanceType > | InstanceDeclarations |
Public Member Functions | |
InstanceMatcher & | operator= (const InstanceMatcher &from) |
const InstanceDeclarations & | getInstanceMap () |
void | setParentFieldDecl (clang::ValueDecl *parent_fd) |
bool | findInstanceByVariableType (clang::CXXRecordDecl *decl, std::vector< InstanceDeclType > &found_instances) |
auto | match_ctor_arg (const std::string &bind_arg_name, const std::string &bind_ctor_expr) |
auto | match_is_derived_sc_module (const std::string &bind_name) |
void | registerMatchers (MatchFinder &finder) |
void | parseVarDecl (clang::VarDecl *instance_decl, std::string &instance_name) |
void | parseFieldDecl (clang::FieldDecl *instance_decl, clang::ValueDecl *parent_decl, std::string instance_name, IndexMapType &index_map) |
virtual void | run (const MatchFinder::MatchResult &result) |
void | dump () |
Private Attributes | |
InstanceDeclarations | instance_map_ |
deprecated | |
clang::ValueDecl * | parent_fd_ |
Class InstanceMatcher.
Definition at line 70 of file InstanceMatcher.h.
std::map<clang::Decl *, ModuleInstanceType> sc_ast_matchers::InstanceMatcher::InstanceDeclarations |
Definition at line 82 of file InstanceMatcher.h.
Definition at line 74 of file InstanceMatcher.h.
std::tuple<std::string, clang::Decl *, ModuleInstanceType> sc_ast_matchers::InstanceMatcher::InstanceDeclType |
Definition at line 73 of file InstanceMatcher.h.
std::pair<clang::Decl *, ModuleInstanceType> sc_ast_matchers::InstanceMatcher::ModuleInstanceTuple |
Store all instances in a map. The map key should be the Decl*. This will work for both FieldDecl (instances within sub-modules) and VarDecl separate modules in sc_main().
Definition at line 81 of file InstanceMatcher.h.
|
inline |
Definition at line 614 of file InstanceMatcher.h.
|
inline |
Definition at line 116 of file InstanceMatcher.h.
|
inline |
Definition at line 108 of file InstanceMatcher.h.
|
inline |
Definition at line 176 of file InstanceMatcher.h.
|
inline |
Definition at line 182 of file InstanceMatcher.h.
|
inline |
Definition at line 103 of file InstanceMatcher.h.
|
inline |
Get all the 1D, 2D and 3D array type pointers.
We need to set the array_type pointer to the deepest array. That is if it is a 3D array then we need to set it to the third dimension element type to get the correct CXXRecordDecl.
Find if an instance already exists. If it does exist.
Definition at line 393 of file InstanceMatcher.h.
|
inline |
This is the main object's constructor name
We do not get the instance name from within the field declaration. Get the type of the class of the field.
auto instance_name{cast<StringLiteral>(ctor_arg)->getString().str()};
Definition at line 348 of file InstanceMatcher.h.
|
inline |
We will have two matchers.
Match when the following conditions are satisifed:
These are field members within a class declaration. Hence, we only need to collect their FieldDecl pointers and their variable names. Their instance names would appear when the constructor of the class that has these field members within it. This constructor would use the initialization list to provide an argument, which would be the instance name.
Add the two matchers.
Definition at line 189 of file InstanceMatcher.h.
|
inlinevirtual |
If parent_fd_ has been set, then use that. Otherwise, pick it up from the matcher.
ctor_fd: Field initialized in the constructor. ctor_init: Constructor initializer. parent_fd: The FieldDecl whose CXXRecordDecl has the initialization. Thus, it is the parent FieldDecl.
For arrays, an InitListExpr is generated. For non-arrays, CXXConstructExpr is directly castable.
If it is an array, then get to its InitListExpr, and then get the first element's constructor.
Definition at line 511 of file InstanceMatcher.h.
|
inline |
Definition at line 110 of file InstanceMatcher.h.
|
private |
deprecated
Instances can come in two forms: FieldDecl: this is when they are members of a class. VarDecl : this is when they are simply variables such as in functions or in the main().
The way to identify them both together is to look at its base class Decl. Then use dyn_cast<> to detect whether it is one of the two above mentioned types. Map of Decl* => ModuleInstanceType
Definition at line 98 of file InstanceMatcher.h.
|
private |
Definition at line 100 of file InstanceMatcher.h.