systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
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
7using namespace systemc_clang;
8
9FindWait::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
22 // Delete all the pointers.
23 for (auto wait : wait_calls_list_) {
24 delete wait;
25 }
26 wait_calls_list_.clear();
27}
28
30
31bool 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(
37 found_wait_ = true;
38 }
39
40 return true;
41}
42
43bool 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(
57 found_wait_ = true;
58 }
59 }
60
61 return true;
62}
63
65
66clang::CXXMethodDecl *FindWait::getEntryMethod() const { return entry_method_decl_; }
67
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}
llvm::raw_ostream & os_
Definition FindWait.h:40
vector< WaitContainer * > waitListType
Definition FindWait.h:20
waitListType wait_calls_list_
Definition FindWait.h:43
FindWait(clang::CXXMethodDecl *, llvm::raw_ostream &)
Definition FindWait.cpp:9
bool shouldVisitTemplateInstantiations() const
Definition FindWait.cpp:29
clang::CXXMethodDecl * getEntryMethod() const
Definition FindWait.cpp:66
virtual bool VisitCallExpr(clang::CallExpr *expr)
Definition FindWait.cpp:43
clang::CallExpr * wait_call_
Definition FindWait.h:41
waitListType getWaitCalls()
Definition FindWait.cpp:64
clang::CXXMethodDecl * entry_method_decl_
Definition FindWait.h:39
bool VisitUnresolvedMemberExpr(clang::UnresolvedMemberExpr *e)
Definition FindWait.cpp:31