systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
FindNotify.cpp
Go to the documentation of this file.
1#include "FindNotify.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;
8using namespace clang;
9
10FindNotify::FindNotify(clang::CXXMethodDecl *d, llvm::raw_ostream &os)
11 : entry_method_decl_(d), os_(os), notify_call_{nullptr} {
12 TraverseDecl(d);
13}
14
16
18
19bool FindNotify::VisitCallExpr(clang::CallExpr *e) {
20 // e->dumpAll();
21 LangOptions LangOpts;
22
23 LangOpts.CPlusPlus = true;
24 PrintingPolicy Policy(LangOpts);
25
26 auto direct_callee{e->getDirectCallee()};
27 if (direct_callee != nullptr) {
28 if (direct_callee->getNameInfo().getAsString() == std::string("notify") &&
29 e->getNumArgs() <= 2) { // need a better checking.....
30 notify_call_list_.push_back(e);
31 // To get the 'x' from x.f(5) I must use getImplicitObjectArgument.
32
33 /*
34 string exprName;
35 if(MemberExpr *me = dyn_cast<MemberExpr>(e->getCallee())) {
36 exprName = getArgumentName(me->getBase()->IgnoreImpCasts());
37 if(_processNotifyEventMap.find(entry_method_decl_) !=
38 _processNotifyEventMap.end()){
39
40 processNotifyEventMapType::iterator processFound =
41 _processNotifyEventMap.find(entry_method_decl_); vector<string> tmp =
42 processFound->second; tmp.push_back(exprName);
43 _processNotifyEventMap.erase(entry_method_decl_);
44 _processNotifyEventMap.insert(processNotifyEventPairType(entry_method_decl_,
45 tmp));
46 }
47 else {
48 vector<string> tmp;
49 tmp.push_back(exprName);
50 _processNotifyEventMap.insert(processNotifyEventPairType(entry_method_decl_,
51 tmp));
52 }
53 }
54 */
55 }
56 }
57 return true;
58}
59
60clang::CXXMethodDecl *FindNotify::getEntryMethod() const {
61 return entry_method_decl_;
62}
63
67
68void FindNotify::dump() const {
69 /*
70 os_ << "\n ============== FindNotify ===============";
71 os_ << "\n:> Print 'notify' statement informtion\n";
72 for (unsigned int i = 0; i < notify_call_list_.size(); i++) {
73 os_ << ":> notify pointer: " << notify_call_list_[i] << ", implicit arg:
74 " << \ getArgumentName(notify_call_list_[i]->getCallee()) << "\n";
75
76 }
77 os_ << "\n ============== END FindNotify ===============";
78 os_ <<"\n Process and events they notify";
79
80 for(processNotifyEventMapType::iterator it =
81 _processNotifyEventMap.begin(), eit = _processNotifyEventMap.end(); it !=
82 eit; it++) { os_ <<"\n Process : "
83 <<it->first->getDeclName().getAsString(); os_ <<"\n Event Notification: ";
84 vector<string> tmp = it->second;
85 for (int i =0; i<tmp.size(); i++) {
86 os_ <<tmp.at(i)<<" ";
87 }
88 }
89 */
90}
std::vector< clang::CallExpr * > NotifyCallListType
Definition FindNotify.h:20
clang::CXXMethodDecl * entry_method_decl_
Definition FindNotify.h:34
bool shouldVisitTemplateInstantiations() const
NotifyCallListType notify_call_list_
Definition FindNotify.h:37
FindNotify(clang::CXXMethodDecl *, llvm::raw_ostream &)
virtual bool VisitCallExpr(clang::CallExpr *expr)
clang::CXXMethodDecl * getEntryMethod() const
NotifyCallListType getNotifyCallList() const
Clang forward declarations.
Definition FindArgument.h:6