Commit 23bba84e authored by Hiren Patel's avatar Hiren Patel
Browse files

Merge branch 'update-format' into 'master'

Formatting should be consistent

See merge request !16
parents 97dfc63f 45775cd8
This diff is collapsed.
#ifndef _AUTOMATA_H_ #ifndef _AUTOMATA_H_
#define _AUTOMATA_H_ #define _AUTOMATA_H_
#include <vector>
#include <deque>
#include <map>
#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclCXX.h"
#include "llvm/Support/raw_ostream.h" #include "clang/AST/Expr.h"
#include "clang/Analysis/CFG.h"
#include "clang/Analysis/CFGStmtMap.h"
#include "clang/AST/ParentMap.h" #include "clang/AST/ParentMap.h"
#include "clang/AST/PrettyPrinter.h" #include "clang/AST/PrettyPrinter.h"
#include "clang/AST/Expr.h" #include "clang/Analysis/CFG.h"
#include "clang/Analysis/CFGStmtMap.h"
#include "llvm/Support/raw_ostream.h"
#include <deque>
#include <map>
#include <stdio.h> #include <stdio.h>
#include <vector>
namespace scpar { namespace scpar {
using namespace clang; using namespace clang;
using namespace std; using namespace std;
class Node {
public:
typedef pair < int, Node * >connectPairType;
typedef map < int, Node * >connectMapType;
Node ( ); class Node {
Node (int ); public:
typedef pair<int, Node *> connectPairType;
typedef map<int, Node *> connectMapType;
void addSuccessor (Node * ); Node();
void addPredecessor (Node * ); Node(int);
vector < int >getSuccessors (int ); void addSuccessor(Node *);
vector < int >getPredecessors (int ); void addPredecessor(Node *);
int getId( );
vector<int> getSuccessors(int);
void dump (raw_ostream &, int ); vector<int> getPredecessors(int);
protected: int getId();
int _id;
connectMapType _preds; void dump(raw_ostream &, int);
connectMapType _succs;
protected:
}; int _id;
connectMapType _preds;
class Edge { connectMapType _succs;
public: };
typedef pair < unsigned int, unsigned int >timePairType; class Edge {
typedef vector < timePairType > timeAdvanceVectorType; public:
typedef pair<unsigned int, unsigned int> timePairType;
Edge (Node *, Node * ); typedef vector<timePairType> timeAdvanceVectorType;
Edge (Node *, Node *, int );
Edge(Node *, Node *);
void updateSuspensionTime(timePairType ); Edge(Node *, Node *, int);
int getId(); void updateSuspensionTime(timePairType);
int getToId();
int getFromId(); int getId();
timeAdvanceVectorType getTimeAdvanceVector(); int getToId();
int getFromId();
void dump (raw_ostream &, int); timeAdvanceVectorType getTimeAdvanceVector();
protected: void dump(raw_ostream &, int);
int _id;
timeAdvanceVectorType _timeAdvanceVector; protected:
Node *_from; int _id;
Node *_to; timeAdvanceVectorType _timeAdvanceVector;
}; Node *_from;
Node *_to;
class Graph { };
public:
class Graph {
typedef vector < int >nodeIDVector; public:
typedef vector < int >edgeIDVector; typedef vector<int> nodeIDVector;
typedef vector<int> edgeIDVector;
typedef vector < Node * >nodeVector;
typedef vector < Edge * >edgeVector; typedef vector<Node *> nodeVector;
typedef vector<Edge *> edgeVector;
typedef map < int, Node * >nodeMapType;
typedef pair < int, Node * >nodePairType; typedef map<int, Node *> nodeMapType;
typedef pair<int, Node *> nodePairType;
typedef map < int, Edge * >edgeMapType;
typedef pair < int, Edge * >edgePairType; typedef map<int, Edge *> edgeMapType;
typedef pair<int, Edge *> edgePairType;
typedef pair < int, int >twoNodePairType;
typedef pair<int, int> twoNodePairType;
typedef pair < twoNodePairType, Edge * >adjPairType;
typedef map < twoNodePairType, Edge * >adjMapType; typedef pair<twoNodePairType, Edge *> adjPairType;
typedef map<twoNodePairType, Edge *> adjMapType;
typedef pair < int, vector < Edge * > >adjEdgesPairType;
typedef map < int, vector < Edge * > >adjEdgesMapType; typedef pair<int, vector<Edge *>> adjEdgesPairType;
typedef map<int, vector<Edge *>> adjEdgesMapType;
Graph();
~Graph(); Graph();
~Graph();
Node *addNode();
Node *addNode(int ); Node *addNode();
Edge *addEdge(Node *, Node * ); Node *addNode(int);
Edge *addEdge(int, int ); Edge *addEdge(Node *, Node *);
Edge *addEdge(int, int);
int getEdgeID(Edge * );
int getEdgeID (Node *, Node * ); int getEdgeID(Edge *);
int getEdgeID (int, int ); int getEdgeID(Node *, Node *);
int getNodeID (Node * ); int getEdgeID(int, int);
int getNodeID(Node *);
Edge *getEdge (Node *, Node * );
Edge *getEdge (int, int ); Edge *getEdge(Node *, Node *);
Node *getNode (int ); Edge *getEdge(int, int);
Node *getNode(int);
vector < Edge * >getEdgesFromSource (int );
vector < Edge * >getEdgesFromSource (Node * ); vector<Edge *> getEdgesFromSource(int);
vector < Edge * >getEdgesFromDest (int ); vector<Edge *> getEdgesFromSource(Node *);
vector < Edge * >getEdgesFromDest (Node * ); vector<Edge *> getEdgesFromDest(int);
vector<Edge *> getEdgesFromDest(Node *);
adjMapType returnAdjList();
nodeIDVector returnNodeIDs(); adjMapType returnAdjList();
edgeIDVector returnEdgeIDs(); nodeIDVector returnNodeIDs();
nodeVector returnNodes(); edgeIDVector returnEdgeIDs();
edgeVector returnEdges(); nodeVector returnNodes();
edgeVector returnEdgeVector(); edgeVector returnEdges();
nodeVector returnNodeVector(); edgeVector returnEdgeVector();
nodeVector returnNodeVector();
void dump (raw_ostream &, int tabn = 0);
void dumpSauto (raw_ostream &, int tabn = 0); void dump(raw_ostream &, int tabn = 0);
protected: void dumpSauto(raw_ostream &, int tabn = 0);
adjMapType _adjList;
nodeMapType _nodeMap; protected:
edgeMapType _edgeMap; adjMapType _adjList;
adjEdgesMapType _adjEdges; nodeMapType _nodeMap;
int _nNodes; edgeMapType _edgeMap;
int _nEdges; adjEdgesMapType _adjEdges;
nodeIDVector _nodeIDVector; int _nNodes;
edgeIDVector _edgeIDVector; int _nEdges;
nodeVector _nodeVector; nodeIDVector _nodeIDVector;
edgeVector _edgeVector; edgeIDVector _edgeIDVector;
}; nodeVector _nodeVector;
} edgeVector _edgeVector;
};
} // namespace scpar
#endif #endif
...@@ -3,223 +3,196 @@ ...@@ -3,223 +3,196 @@
using namespace scpar; using namespace scpar;
EntryFunctionContainer::~EntryFunctionContainer () EntryFunctionContainer::~EntryFunctionContainer() {
{ // DO NOT free anything.
// DO NOT free anything.
} }
EntryFunctionContainer::EntryFunctionContainer () : EntryFunctionContainer::EntryFunctionContainer()
_entryName ("NONE"), : _entryName("NONE"), _procType(PROCESS_TYPE::NONE),
_procType (PROCESS_TYPE::NONE), _entryMethodDecl(nullptr) {}
_entryMethodDecl (nullptr) {
} EntryFunctionContainer::EntryFunctionContainer(string n, PROCESS_TYPE p,
CXXMethodDecl *d, Stmt *s)
EntryFunctionContainer::EntryFunctionContainer (string n, PROCESS_TYPE p, CXXMethodDecl * d, Stmt * s) : _entryName(n), _procType(p), _entryMethodDecl(d) {}
:_entryName (n), _procType (p), _entryMethodDecl (d) {
}
EntryFunctionContainer::EntryFunctionContainer (const EntryFunctionContainer & from) { EntryFunctionContainer::EntryFunctionContainer(
_entryName = from._entryName; const EntryFunctionContainer &from) {
_procType = from._procType; _entryName = from._entryName;
_entryMethodDecl = from._entryMethodDecl; _procType = from._procType;
_entryMethodDecl = from._entryMethodDecl;
} }
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
string EntryFunctionContainer::getName () string EntryFunctionContainer::getName() { return _entryName; }
{
return _entryName;
}
FindSensitivity::senseMapType EntryFunctionContainer::getSenseMap() { FindSensitivity::senseMapType EntryFunctionContainer::getSenseMap() {
return _senseMap; return _senseMap;
} }
CXXMethodDecl* EntryFunctionContainer::getEntryMethod () CXXMethodDecl *EntryFunctionContainer::getEntryMethod() {
{ return _entryMethodDecl;
return _entryMethodDecl;
} }
EntryFunctionContainer::waitContainerListType EntryFunctionContainer::getWaitCalls () EntryFunctionContainer::waitContainerListType
{ EntryFunctionContainer::getWaitCalls() {
return _waitCalls; return _waitCalls;
} }
EntryFunctionContainer::notifyContainerListType EntryFunctionContainer::getNotifyCalls() { EntryFunctionContainer::notifyContainerListType
return _notifyCalls; EntryFunctionContainer::getNotifyCalls() {
return _notifyCalls;
} }
PROCESS_TYPE EntryFunctionContainer::getProcessType () PROCESS_TYPE EntryFunctionContainer::getProcessType() { return _procType; }
{
return _procType;
}
SuspensionAutomata::susCFGVectorType EntryFunctionContainer::getSusCFG() { SuspensionAutomata::susCFGVectorType EntryFunctionContainer::getSusCFG() {
return _susCFG; return _susCFG;
//return _instanceSusCFGMap[numInstance]; // return _instanceSusCFGMap[numInstance];
} }
SuspensionAutomata::transitionVectorType EntryFunctionContainer::getSusAuto() { SuspensionAutomata::transitionVectorType EntryFunctionContainer::getSusAuto() {
return _susAuto; return _susAuto;
//return _instanceSautoMap[numInstance]; // return _instanceSautoMap[numInstance];
} }
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
void EntryFunctionContainer::setName (string n) void EntryFunctionContainer::setName(string n) { _entryName = n; }
{
_entryName = n;
}
void EntryFunctionContainer::setProcessType (PROCESS_TYPE p) void EntryFunctionContainer::setProcessType(PROCESS_TYPE p) { _procType = p; }
{
_procType = p;
}
void EntryFunctionContainer::setEntryMethod (CXXMethodDecl * d) void EntryFunctionContainer::setEntryMethod(CXXMethodDecl *d) {
{ _entryMethodDecl = d;
_entryMethodDecl = d;
} }
void EntryFunctionContainer::addSensitivityInfo(FindSensitivity &s) { void EntryFunctionContainer::addSensitivityInfo(FindSensitivity &s) {
_senseMap = s.getSenseMap(); _senseMap = s.getSenseMap();
} }
void EntryFunctionContainer::addWaits(FindWait &f) {
void EntryFunctionContainer::addWaits (FindWait & f) FindWait::waitListType wcalls = f.getWaitCalls();
{ for (FindWait::waitListType::iterator it = wcalls.begin(), eit = wcalls.end();
FindWait::waitListType wcalls = f.getWaitCalls (); it != eit; it++) {
for (FindWait::waitListType::iterator it = wcalls.begin (), eit = // 'it' points to CXXMembercallExpr type.
wcalls.end (); it != eit; it++) { WaitContainer *wc{
// 'it' points to CXXMembercallExpr type. new WaitContainer(f.getEntryMethod(), (*it)->getASTNode())};
WaitContainer * wc { new WaitContainer (f.getEntryMethod (), (*it)->getASTNode() ) }; _waitCalls.push_back(wc);
_waitCalls.push_back(wc); }
} //_processWaitEventMap = f.getProcessWaitEventMap();
//_processWaitEventMap = f.getProcessWaitEventMap();
} }
void EntryFunctionContainer::addSusCFGAuto(SuspensionAutomata &s) { void EntryFunctionContainer::addSusCFGAuto(SuspensionAutomata &s) {
_susCFG = s.getSusCFG(); _susCFG = s.getSusCFG();
_susAuto = s.getSauto(); _susAuto = s.getSauto();
/* /*
if (_instanceSusCFGMap.find(numInstance) == _instanceSusCFGMap.end() && _instanceSautoMap.find(numInstance) == _instanceSautoMap.end()) { if (_instanceSusCFGMap.find(numInstance) == _instanceSusCFGMap.end() &&
_instanceSautoMap.find(numInstance) == _instanceSautoMap.end()) {
_instanceSusCFGMap.insert(instanceSusCFGPairType(numInstance, s.getSusCFG()));
_instanceSautoMap.insert(instanceSautoPairType(numInstance, s.getSauto())); _instanceSusCFGMap.insert(instanceSusCFGPairType(numInstance,
} s.getSusCFG())); _instanceSautoMap.insert(instanceSautoPairType(numInstance,
*/ s.getSauto()));
}
*/
} }
void EntryFunctionContainer::addNotifys( FindNotify& f) { void EntryFunctionContainer::addNotifys(FindNotify &f) {
FindNotify::NotifyCallListType ncalls = f.getNotifyCallList(); FindNotify::NotifyCallListType ncalls = f.getNotifyCallList();
for (FindNotify::NotifyCallListType::iterator it = ncalls.begin(), eit = ncalls.end(); for (FindNotify::NotifyCallListType::iterator it = ncalls.begin(),
it != eit; eit = ncalls.end();
it++) { it != eit; it++) {
// 'it' points to CXXMembercallExpr type. // 'it' points to CXXMembercallExpr type.
NotifyContainer* nc = new NotifyContainer(f.getEntryMethod(), *it); NotifyContainer *nc = new NotifyContainer(f.getEntryMethod(), *it);
_notifyCalls.push_back(nc); _notifyCalls.push_back(nc);
} }
//_processWaitEventMap = f.getProcessWaitEventMap(); //_processWaitEventMap = f.getProcessWaitEventMap();
} }
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
void EntryFunctionContainer::dumpSusCFG(raw_ostream & os) void EntryFunctionContainer::dumpSusCFG(raw_ostream &os) {
{
os << "\n#############################################"; os << "\n#############################################";
SuspensionAutomata::susCFGVectorType susCFGVector = _susCFG; SuspensionAutomata::susCFGVectorType susCFGVector = _susCFG;
for (unsigned int i = 0; i < susCFGVector.size(); i++) { for (unsigned int i = 0; i < susCFGVector.size(); i++) {
os << "\n Block ID : " << susCFGVector.at(i)->getBlockID(); os << "\n Block ID : " << susCFGVector.at(i)->getBlockID();
os << "\n Is Wait Block : " << susCFGVector.at(i)->isWaitBlock(); os << "\n Is Wait Block : " << susCFGVector.at(i)->isWaitBlock();
if (susCFGVector.at(i)->getParentBlockID()) { if (susCFGVector.at(i)->getParentBlockID()) {
os << "\n Parent ID : " << susCFGVector.at(i)->getParentBlockID(); os << "\n Parent ID : " << susCFGVector.at(i)->getParentBlockID();
SusCFG *parentBlock = susCFGVector.at(i)->getParentSusCFGBlock(); SusCFG *parentBlock = susCFGVector.at(i)->getParentSusCFGBlock();
os << "\n Parent Block ID : " << parentBlock->getBlockID(); os << "\n Parent Block ID : " << parentBlock->getBlockID();
os << "\n Size of Children : " << parentBlock->getChildBlockList().size(); os << "\n Size of Children : " << parentBlock->getChildBlockList().size();
} }
vector < SusCFG * >predBlocks = susCFGVector.at(i)->getPredBlocks(); vector<SusCFG *> predBlocks = susCFGVector.at(i)->getPredBlocks();
vector < SusCFG * >succBlocks = susCFGVector.at(i)->getSuccBlocks(); vector<SusCFG *> succBlocks = susCFGVector.at(i)->getSuccBlocks();
os << "\n Predecessor Blocks : "; os << "\n Predecessor Blocks : ";
for (unsigned int j = 0; j < predBlocks.size(); j++) { for (unsigned int j = 0; j < predBlocks.size(); j++) {
if (predBlocks.at(j)) { if (predBlocks.at(j)) {
os << predBlocks.at(j)->getBlockID() << " "; os << predBlocks.at(j)->getBlockID() << " ";
} }
} }
os << "\n Successor Blocks : "; os << "\n Successor Blocks : ";
for (unsigned int j = 0; j < succBlocks.size(); j++) { for (unsigned int j = 0; j < succBlocks.size(); j++) {
if (succBlocks.at(j)) { if (succBlocks.at(j)) {
os << succBlocks.at(j)->getBlockID() << " "; os << succBlocks.at(j)->getBlockID() << " ";
} }
} }
} }
} }
void EntryFunctionContainer::dumpSauto(raw_ostream & os) void EntryFunctionContainer::dumpSauto(raw_ostream &os) {
{ vector<Transition *> transitionVector = _susAuto;
vector < Transition * >transitionVector = _susAuto; os << "\n Size of transitionVector : " << transitionVector.size();
os << "\n Size of transitionVector : " << transitionVector.size(); for (unsigned int i = 0; i < transitionVector.size(); i++) {
for (unsigned int i = 0; i < transitionVector.size(); i++) { Transition *t = transitionVector.at(i);
Transition *t = transitionVector.at(i); t->dump(os);
t->dump(os); }
} }
}
void EntryFunctionContainer::dump(raw_ostream &os, int tabn) {
os << "\n";
for (int i = 0; i < tabn; i++) {
void EntryFunctionContainer::dump (raw_ostream & os, int tabn) os << " ";
{ }
os << "\n";
for (int i = 0; i < tabn; i++) os << "EntryFunctionContainer '" << getName() << "' processType '";
{ switch (getProcessType()) {
os << " "; case PROCESS_TYPE::THREAD:
} os << "SC_THREAD' ";
break;
os << "EntryFunctionContainer '" << getName () << "' processType '"; case PROCESS_TYPE::METHOD:
switch (getProcessType ()) os << "SC_METHOD' ";
{ break;
case PROCESS_TYPE::THREAD: case PROCESS_TYPE::CTHREAD:
os << "SC_THREAD' "; os << "SC_CTHREAD' ";
break; break;
case PROCESS_TYPE::METHOD: default:
os << "SC_METHOD' "; os << "NONE' ";
break; break;
case PROCESS_TYPE::CTHREAD: }
os << "SC_CTHREAD' ";
break; os << " CXXMethodDecl '" << getEntryMethod() << "\n";
default: int newTabn = ++tabn;
os << "NONE' ";
break; os << " Wait Calls \n";
} for (waitContainerListType::iterator it = _waitCalls.begin(),
eit = _waitCalls.end();
os << " CXXMethodDecl '" << getEntryMethod () << "\n"; it != eit; it++) {
int newTabn = ++tabn;
(*it)->dump(os, newTabn);
os <<" Wait Calls \n"; }
for (waitContainerListType::iterator it = _waitCalls.begin (), eit = os << " Notify Calls \n";
_waitCalls.end (); it != eit; it++) for (notifyContainerListType::iterator it = _notifyCalls.begin(),
{ eit = _notifyCalls.end();
it != eit; it++) {
(*it)->dump (os, newTabn); (*it)->dump(os, newTabn);
} }
os <<" Notify Calls \n";
for (notifyContainerListType::iterator it = _notifyCalls.begin(), eit = _notifyCalls.end(); os << "\n Suspension CFG";
it != eit; os << "\n ###############";
it++ ) {