systemc-clang
2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
src
matchers
FindWait.cpp
Go to the documentation of this file.
1
#include "
FindWait.h
"
2
#include "clang/AST/DeclTemplate.h"
3
#include "clang/AST/PrettyPrinter.h"
4
#include "clang/AST/Type.h"
5
//#include "clang/Basic/SourceManager.h"
6
7
using namespace
systemc_clang
;
8
9
FindWait::FindWait
(clang::CXXMethodDecl *d, llvm::raw_ostream &os)
10
: entry_method_decl_{d}, os_{os}, wait_call_{nullptr}, found_wait_{false} {
11
TraverseDecl(d);
12
13
// If there was a wait that was found. Then go through and dump them all out?
14
if
(
found_wait_
) {
15
for
(
auto
wait :
wait_calls_list_
) {
16
wait->dump(
os_
, 2);
17
}
18
}
19
}
20
21
FindWait::~FindWait
() {
22
// Delete all the pointers.
23
for
(
auto
wait :
wait_calls_list_
) {
24
delete
wait;
25
}
26
wait_calls_list_
.clear();
27
}
28
29
bool
FindWait::shouldVisitTemplateInstantiations
()
const
{
return
true
; }
30
31
bool
FindWait::VisitUnresolvedMemberExpr
(UnresolvedMemberExpr *e) {
32
// This is for the templated wait calls.
33
// e should not be null if it gets here.
34
if
(e->getMemberNameInfo().getAsString() == std::string(
"wait"
)) {
35
wait_calls_list_
.push_back(
36
new
WaitContainer
(
entry_method_decl_
,
wait_call_
));
37
found_wait_
=
true
;
38
}
39
40
return
true
;
41
}
42
43
bool
FindWait::VisitCallExpr
(CallExpr *e) {
44
clang::LangOptions LangOpts;
45
LangOpts.CPlusPlus =
true
;
46
clang::PrintingPolicy Policy(LangOpts);
47
48
// This allows templated wait calls to refer to the CallExpr as well.
49
wait_call_
= e;
50
// Check if the non-templated wait has a "wait" in it.
51
auto
direct_callee{e->getDirectCallee()};
52
if
((direct_callee !=
nullptr
)) {
53
if
((direct_callee->getNameInfo().getAsString() == std::string(
"wait"
))) {
54
// Insert the information to parse the wait arguments.
55
wait_calls_list_
.push_back(
56
new
WaitContainer
(
entry_method_decl_
,
wait_call_
));
57
found_wait_
=
true
;
58
}
59
}
60
61
return
true
;
62
}
63
64
FindWait::waitListType
FindWait::getWaitCalls
() {
return
wait_calls_list_
; }
65
66
clang::CXXMethodDecl *
FindWait::getEntryMethod
()
const
{
return
entry_method_decl_
; }
67
68
void
FindWait::dump
() {
69
/*
70
os_ << "\n ============== FindWait ===============";
71
os_ << "\n:> Print 'wait' statement informtion\n";
72
for (unsigned int i = 0; i < wait_calls_list_.size(); i++) {
73
if(wait_calls_list_.size() > 2) {
74
os_ << ":> wait pointer: " << wait_calls_list_[i] << "num. of args: " <<
75
wait_calls_list_[i]->getNumArgs()-1 << "\n";
76
77
for (unsigned int j = 0; j < wait_calls_list_[i]->getNumArgs()-1; j++) {
78
os_ << "- arg " << j << ": " <<
79
getArgumentName(wait_calls_list_[i]->getArg(j))
80
<< "\n";
81
}
82
}
83
else {
84
os_ << ":> wait pointer: " << wait_calls_list_[i] << "num. of args: " <<
85
wait_calls_list_[i]->getNumArgs() << "\n";
86
87
for (unsigned int j = 0; j < wait_calls_list_[i]->getNumArgs(); j++) {
88
os_ << "- arg " << j << ": " <<
89
getArgumentName(wait_calls_list_[i]->getArg(j))
90
<< "\n";
91
}
92
}
93
}
94
95
os_ << "\n ============== END FindWait ===============";
96
97
os_ <<"\n Process and waiting on events ";
98
for (processWaitEventMapType::iterator it = _processWaitEventMap.begin(),
99
eit = _processWaitEventMap.end(); it != eit; it++) { os_ <<"\n Process :"
100
<<it->first->getDeclName().getAsString();
101
102
os_ <<"\n Waiting on event(s) : ";
103
vector<string> tmp = it->second;
104
for (int i = 0; i<tmp.size(); i++) {
105
os_ <<tmp.at(i)<<" ";
106
}
107
}
108
*/
109
}
FindWait.h
systemc_clang::FindWait::os_
llvm::raw_ostream & os_
Definition
FindWait.h:40
systemc_clang::FindWait::~FindWait
virtual ~FindWait()
Definition
FindWait.cpp:21
systemc_clang::FindWait::waitListType
vector< WaitContainer * > waitListType
Definition
FindWait.h:20
systemc_clang::FindWait::wait_calls_list_
waitListType wait_calls_list_
Definition
FindWait.h:43
systemc_clang::FindWait::dump
void dump()
Definition
FindWait.cpp:68
systemc_clang::FindWait::FindWait
FindWait(clang::CXXMethodDecl *, llvm::raw_ostream &)
Definition
FindWait.cpp:9
systemc_clang::FindWait::shouldVisitTemplateInstantiations
bool shouldVisitTemplateInstantiations() const
Definition
FindWait.cpp:29
systemc_clang::FindWait::found_wait_
bool found_wait_
Definition
FindWait.h:42
systemc_clang::FindWait::getEntryMethod
clang::CXXMethodDecl * getEntryMethod() const
Definition
FindWait.cpp:66
systemc_clang::FindWait::VisitCallExpr
virtual bool VisitCallExpr(clang::CallExpr *expr)
Definition
FindWait.cpp:43
systemc_clang::FindWait::wait_call_
clang::CallExpr * wait_call_
Definition
FindWait.h:41
systemc_clang::FindWait::getWaitCalls
waitListType getWaitCalls()
Definition
FindWait.cpp:64
systemc_clang::FindWait::entry_method_decl_
clang::CXXMethodDecl * entry_method_decl_
Definition
FindWait.h:39
systemc_clang::FindWait::VisitUnresolvedMemberExpr
bool VisitUnresolvedMemberExpr(clang::UnresolvedMemberExpr *e)
Definition
FindWait.cpp:31
systemc_clang::WaitContainer
Definition
WaitContainer.h:14
systemc_clang
Definition
SplitCFG.h:10
Generated by
1.12.0