Commit f78f5cd5 authored by rmrf's avatar rmrf
Browse files

Clean up code

parent 177bb1ac
......@@ -117,8 +117,8 @@ void EntryFunctionContainer::addSusCFGAuto(SuspensionAutomata &s) {
}
void EntryFunctionContainer::addNotifys( FindNotify& f) {
FindNotify::notifyCallListType ncalls = f.getNotifyCallList();
for (FindNotify::notifyCallListType::iterator it = ncalls.begin(), eit = ncalls.end();
FindNotify::NotifyCallListType ncalls = f.getNotifyCallList();
for (FindNotify::NotifyCallListType::iterator it = ncalls.begin(), eit = ncalls.end();
it != eit;
it++) {
// 'it' points to CXXMembercallExpr type.
......
......@@ -7,62 +7,55 @@
using namespace scpar;
using namespace std;
FindNotify::FindNotify (CXXMethodDecl * d, llvm::raw_ostream & os):
_entryMethodDecl (d), _os (os), _notifyCall (NULL)
{
TraverseDecl (d);
FindNotify::FindNotify( CXXMethodDecl *d, llvm::raw_ostream &os ) :
entry_method_decl_(d),
os_(os),
notify_call_{nullptr} {
TraverseDecl(d);
}
FindNotify::~FindNotify ()
{
_notifyCalls.clear ();
FindNotify::~FindNotify() {
notify_call_list_.clear();
}
bool FindNotify::VisitCallExpr (CallExpr * e)
{
bool FindNotify::VisitCallExpr( CallExpr * e ) {
// e->dumpAll();
LangOptions
LangOpts;
LangOptions LangOpts;
LangOpts.CPlusPlus = true;
PrintingPolicy
Policy (LangOpts
);
if (e->getDirectCallee ()->getNameInfo ().getAsString () ==
string ("notify") && e->getNumArgs () <= 2)
{ // need a better checking.....
_notifyCalls.push_back (e);
// To get the 'x' from x.f(5) I must use getImplicitObjectArgument.
/*
string exprName;
if(MemberExpr *me = dyn_cast<MemberExpr>(e->getCallee())) {
exprName = getArgumentName(me->getBase()->IgnoreImpCasts());
if(_processNotifyEventMap.find(_entryMethodDecl) != _processNotifyEventMap.end()){
processNotifyEventMapType::iterator processFound = _processNotifyEventMap.find(_entryMethodDecl);
vector<string> tmp = processFound->second;
tmp.push_back(exprName);
_processNotifyEventMap.erase(_entryMethodDecl);
_processNotifyEventMap.insert(processNotifyEventPairType(_entryMethodDecl, tmp));
}
else {
vector<string> tmp;
tmp.push_back(exprName);
_processNotifyEventMap.insert(processNotifyEventPairType(_entryMethodDecl, tmp));
}
}
*/
}
PrintingPolicy Policy(LangOpts);
if (e->getDirectCallee()->getNameInfo().getAsString() == string ("notify") && e->getNumArgs () <= 2) { // need a better checking.....
notify_call_list_.push_back(e);
// To get the 'x' from x.f(5) I must use getImplicitObjectArgument.
/*
string exprName;
if(MemberExpr *me = dyn_cast<MemberExpr>(e->getCallee())) {
exprName = getArgumentName(me->getBase()->IgnoreImpCasts());
if(_processNotifyEventMap.find(entry_method_decl_) != _processNotifyEventMap.end()){
processNotifyEventMapType::iterator processFound = _processNotifyEventMap.find(entry_method_decl_);
vector<string> tmp = processFound->second;
tmp.push_back(exprName);
_processNotifyEventMap.erase(entry_method_decl_);
_processNotifyEventMap.insert(processNotifyEventPairType(entry_method_decl_, tmp));
}
else {
vector<string> tmp;
tmp.push_back(exprName);
_processNotifyEventMap.insert(processNotifyEventPairType(entry_method_decl_, tmp));
}
}
*/
}
return true;
}
/*
string FindNotify::getArgumentName(Expr* arg) {
string FindNotify::getArgumentName(Expr* arg) {
if (arg == NULL) {
return string("NULL");
return string("NULL");
}
LangOptions LangOpts;
......@@ -74,42 +67,38 @@ string FindNotify::getArgumentName(Expr* arg) {
arg->printPretty(s, 0, Policy);
return s.str();
}
}
*/
CXXMethodDecl * FindNotify::getEntryMethod() {
return _entryMethodDecl;
CXXMethodDecl * FindNotify::getEntryMethod() const {
return entry_method_decl_;
}
FindNotify::notifyCallListType FindNotify::getNotifyCallList ()
{
return _notifyCalls;
FindNotify::NotifyCallListType FindNotify::getNotifyCallList() const {
return notify_call_list_;
}
void
FindNotify::dump (
)
{
/*
_os << "\n ============== FindNotify ===============";
_os << "\n:> Print 'notify' statement informtion\n";
for (unsigned int i = 0; i < _notifyCalls.size(); i++) {
_os << ":> notify pointer: " << _notifyCalls[i] << ", implicit arg: " << \
getArgumentName(_notifyCalls[i]->getCallee()) << "\n";
}
_os << "\n ============== END FindNotify ===============";
_os <<"\n Process and events they notify";
void FindNotify::dump() const {
/*
os_ << "\n ============== FindNotify ===============";
os_ << "\n:> Print 'notify' statement informtion\n";
for (unsigned int i = 0; i < notify_call_list_.size(); i++) {
os_ << ":> notify pointer: " << notify_call_list_[i] << ", implicit arg: " << \
getArgumentName(notify_call_list_[i]->getCallee()) << "\n";
}
os_ << "\n ============== END FindNotify ===============";
os_ <<"\n Process and events they notify";
for(processNotifyEventMapType::iterator it = _processNotifyEventMap.begin(), eit = _processNotifyEventMap.end();
for(processNotifyEventMapType::iterator it = _processNotifyEventMap.begin(), eit = _processNotifyEventMap.end();
it != eit;
it++) {
_os <<"\n Process : " <<it->first->getDeclName().getAsString();
_os <<"\n Event Notification: ";
os_ <<"\n Process : " <<it->first->getDeclName().getAsString();
os_ <<"\n Event Notification: ";
vector<string> tmp = it->second;
for (int i =0; i<tmp.size(); i++) {
_os <<tmp.at(i)<<" ";
os_ <<tmp.at(i)<<" ";
}
}
*/
}
*/
}
......@@ -12,22 +12,21 @@ namespace scpar {
class FindNotify:public RecursiveASTVisitor < FindNotify > {
public:
typedef vector < CallExpr * > notifyCallListType;
typedef vector < CallExpr * > NotifyCallListType;
FindNotify(CXXMethodDecl *, raw_ostream &);
FindNotify( CXXMethodDecl *, raw_ostream & );
virtual ~FindNotify();
virtual bool VisitCallExpr (CallExpr *expr);
virtual bool VisitCallExpr ( CallExpr *expr );
notifyCallListType getNotifyCallList ();
CXXMethodDecl * getEntryMethod();
void dump();
NotifyCallListType getNotifyCallList() const;
CXXMethodDecl * getEntryMethod() const;
void dump() const;
private:
CXXMethodDecl * _entryMethodDecl;
raw_ostream & _os;
CallExpr *_notifyCall;
notifyCallListType _notifyCalls;
CXXMethodDecl *entry_method_decl_;
llvm::raw_ostream &os_;
CallExpr *notify_call_;
NotifyCallListType notify_call_list_;
};
}
#endif
......@@ -7,20 +7,20 @@
using namespace scpar;
using namespace std;
FindWait::FindWait (CXXMethodDecl *d, llvm::raw_ostream &os):
_entryMethodDecl(d),
_os(os),
_waitCall(nullptr),
_firstArg(nullptr),
_foundWait (false) {
TraverseDecl(d);
FindWait::FindWait( CXXMethodDecl *d, llvm::raw_ostream &os ) :
entry_method_decl_{d},
os_{os},
wait_call_{nullptr} { //},
// first_arg_{nullptr},
// found_wait_{false} {
TraverseDecl(d);
}
FindWait::~FindWait() {
_waitCalls.clear ();
wait_calls_list_.clear();
}
bool FindWait::VisitCallExpr (CallExpr *e) {
bool FindWait::VisitCallExpr ( CallExpr *e ) {
// bool duplicateWait = false;
......@@ -28,55 +28,54 @@ bool FindWait::VisitCallExpr (CallExpr *e) {
LangOpts.CPlusPlus = true;
clang::PrintingPolicy Policy (LangOpts);
if (e->getDirectCallee ()->getNameInfo ().getAsString () == string ("wait")) {
_waitCalls.push_back (e);
}
if (e->getDirectCallee()->getNameInfo().getAsString() == string("wait")) {
wait_calls_list_.push_back (e);
}
return true;
}
FindWait::waitListType FindWait::getWaitCalls() {
return _waitCalls;
return wait_calls_list_;
}
CXXMethodDecl* FindWait::getEntryMethod() {
return _entryMethodDecl;
CXXMethodDecl* FindWait::getEntryMethod() const {
return entry_method_decl_;
}
void FindWait::dump() {
/*
_os << "\n ============== FindWait ===============";
_os << "\n:> Print 'wait' statement informtion\n";
for (unsigned int i = 0; i < _waitCalls.size(); i++) {
if(_waitCalls.size() > 2) {
_os << ":> wait pointer: " << _waitCalls[i] << "num. of args: " << _waitCalls[i]->getNumArgs()-1 << "\n";
for (unsigned int j = 0; j < _waitCalls[i]->getNumArgs()-1; j++) {
_os << "- arg " << j << ": " << getArgumentName(_waitCalls[i]->getArg(j)) << "\n";
}
}
else {
_os << ":> wait pointer: " << _waitCalls[i] << "num. of args: " << _waitCalls[i]->getNumArgs() << "\n";
for (unsigned int j = 0; j < _waitCalls[i]->getNumArgs(); j++) {
_os << "- arg " << j << ": " << getArgumentName(_waitCalls[i]->getArg(j)) << "\n";
}
}
}
_os << "\n ============== END FindWait ===============";
_os <<"\n Process and waiting on events ";
for (processWaitEventMapType::iterator it = _processWaitEventMap.begin(), eit = _processWaitEventMap.end();
it != eit;
it++) {
_os <<"\n Process :" <<it->first->getDeclName().getAsString();
_os <<"\n Waiting on event(s) : ";
vector<string> tmp = it->second;
for (int i = 0; i<tmp.size(); i++) {
_os <<tmp.at(i)<<" ";
}
}
*/
os_ << "\n ============== FindWait ===============";
os_ << "\n:> Print 'wait' statement informtion\n";
for (unsigned int i = 0; i < wait_calls_list_.size(); i++) {
if(wait_calls_list_.size() > 2) {
os_ << ":> wait pointer: " << wait_calls_list_[i] << "num. of args: " << wait_calls_list_[i]->getNumArgs()-1 << "\n";
for (unsigned int j = 0; j < wait_calls_list_[i]->getNumArgs()-1; j++) {
os_ << "- arg " << j << ": " << getArgumentName(wait_calls_list_[i]->getArg(j)) << "\n";
}
}
else {
os_ << ":> wait pointer: " << wait_calls_list_[i] << "num. of args: " << wait_calls_list_[i]->getNumArgs() << "\n";
for (unsigned int j = 0; j < wait_calls_list_[i]->getNumArgs(); j++) {
os_ << "- arg " << j << ": " << getArgumentName(wait_calls_list_[i]->getArg(j)) << "\n";
}
}
}
os_ << "\n ============== END FindWait ===============";
os_ <<"\n Process and waiting on events ";
for (processWaitEventMapType::iterator it = _processWaitEventMap.begin(), eit = _processWaitEventMap.end();
it != eit;
it++) {
os_ <<"\n Process :" <<it->first->getDeclName().getAsString();
os_ <<"\n Waiting on event(s) : ";
vector<string> tmp = it->second;
for (int i = 0; i<tmp.size(); i++) {
os_ <<tmp.at(i)<<" ";
}
}
*/
}
......@@ -18,24 +18,22 @@ namespace scpar {
typedef pair < CXXMethodDecl *,vector < string > >processWaitEventPairType;
typedef map < CXXMethodDecl *, vector < string > >processWaitEventMapType;
FindWait (CXXMethodDecl *, llvm::raw_ostream &);
FindWait( CXXMethodDecl *, llvm::raw_ostream & );
virtual ~FindWait();
virtual bool VisitCallExpr(CallExpr *expr);
virtual bool VisitCallExpr( CallExpr *expr );
CXXMethodDecl* getEntryMethod();
CXXMethodDecl* getEntryMethod() const;
waitListType getWaitCalls();
void dump();
private:
CXXMethodDecl *_entryMethodDecl;
llvm::raw_ostream & _os;
CallExpr *_waitCall;
Expr *_firstArg;
bool _foundWait;
waitListType _waitCalls;
CXXMethodDecl *entry_method_decl_;
llvm::raw_ostream & os_;
CallExpr *wait_call_;
// Expr *first_arg_;
// bool found_wait_;
waitListType wait_calls_list_;
};
}
......
......@@ -139,7 +139,7 @@ unsigned int Model::getNumEvents()
void Model::dump(raw_ostream & os)
{
int counterModel = 0;
// int counterModel = 0;
os << "\nNumber of Models : " << _modules.size();
......
......@@ -4,62 +4,42 @@
using namespace scpar;
using namespace std;
NotifyCalls::~NotifyCalls ()
{
NotifyCalls::~NotifyCalls() {
// _astNode does *NOT* need to be deleted because clang should
// be responsible for freeing the memory.
}
NotifyCalls::NotifyCalls ():
_name ("NONE")
{
NotifyCalls::NotifyCalls() :
_name{"NONE"} {
}
NotifyCalls::NotifyCalls (const string & name, FindNotify::notifyCallListType notifyCallList
):
_name (name
),
_notifyCallList (notifyCallList
)
{
NotifyCalls::NotifyCalls(const string & name, FindNotify::NotifyCallListType notifyCallList ) :
_name{name},
_notifyCallList{notifyCallList} {
}
NotifyCalls::NotifyCalls (const NotifyCalls & from
)
{
NotifyCalls::NotifyCalls( const NotifyCalls & from ) {
_name = from._name;
_notifyCallList = from._notifyCallList;
}
string NotifyCalls::getName ()
{
string NotifyCalls::getName() const {
return _name;
}
FindNotify::notifyCallListType NotifyCalls::getNotifyCallList ()
{
FindNotify::NotifyCallListType NotifyCalls::getNotifyCallList() {
return _notifyCallList;
}
unsigned int
NotifyCalls::getNumNotifyCalls (
)
{
unsigned int NotifyCalls::getNumNotifyCalls() {
return _notifyCallList.size ();
}
void
NotifyCalls::dump (raw_ostream & os, int tabn
)
{
for (unsigned int i = 0; i < _notifyCallList.size (); i++)
{
os << "\n Notify Call: " << _notifyCallList.at (i);
}
void NotifyCalls::dump ( llvm::raw_ostream & os, int tabn ) {
for ( auto i{0}; i < _notifyCallList.size (); ++i ) {
os << "\n Notify Call: " << _notifyCallList.at (i);
}
}
......@@ -19,43 +19,34 @@
#include <map>
#include "Utility.h"
#include "FindNotify.h"
namespace scpar {
using namespace clang;
using namespace std;
class NotifyCalls {
public:
// Constructors.
NotifyCalls (
);
NotifyCalls (const string &, FindNotify::notifyCallListType
);
NotifyCalls();
NotifyCalls( const string &, FindNotify::NotifyCallListType );
// Copy constructor.
NotifyCalls (const NotifyCalls &
);
NotifyCalls (const NotifyCalls & );
// Destructor.
~NotifyCalls (
);
~NotifyCalls();
/// Get parameters
string getName (
);
FindNotify::notifyCallListType getNotifyCallList (
);
string getName() const;
FindNotify::NotifyCallListType getNotifyCallList();
unsigned int getNumNotifyCalls (
);
unsigned int getNumNotifyCalls();
// Print
void dump (raw_ostream &, int
);
void dump ( llvm::raw_ostream &, int );
private:
string _name;
FindNotify::notifyCallListType _notifyCallList;
FindNotify::NotifyCallListType _notifyCallList;
};
}
#endif
......@@ -82,7 +82,7 @@ namespace scpar {
instanceFunctionSautoMapType _instanceFunctionSautoMap;
eventNotificationTimeMapType _eventNotificationTimeMap;
transitionTimeMapType _transitionTimeMap;
FindNotify::notifyCallListType _notifyCalls;
FindNotify::NotifyCallListType _notifyCalls;
visitTransitionMapType _visitTransitionMap;
entryFunctionMacroMapType _entryFunctionGPUMacroMap;
susCFGBlockGPUMacroMapType _susCFGBlockGPUMacroMap;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment