Commit c0e79eb6 authored by Hiren Patel's avatar Hiren Patel

Merge branch 'sauto-compile-fix' into 'master'

sauto files need careful inspection before removing warnings

See merge request !15
parents c779d140 22c0fa2a
...@@ -53,7 +53,7 @@ void SusCFG::addChildBlockList(SusCFG * block) ...@@ -53,7 +53,7 @@ void SusCFG::addChildBlockList(SusCFG * block)
void SusCFG::addChildBlockList(vector < SusCFG * >blockList) void SusCFG::addChildBlockList(vector < SusCFG * >blockList)
{ {
for (size_t i = 0; i < blockList.size(); i++) { for (unsigned int i = 0; i < blockList.size(); i++) {
_childBlockList.push_back(blockList.at(i)); _childBlockList.push_back(blockList.at(i));
} }
} }
...@@ -249,8 +249,9 @@ void Transition::addCodeBlocks(SusCFG * susCFG) ...@@ -249,8 +249,9 @@ void Transition::addCodeBlocks(SusCFG * susCFG)
_codeBlockVector.push_back(susCFG); _codeBlockVector.push_back(susCFG);
} }
void Transition::addCodeBlocks(vector < SusCFG * >susCFG) { void Transition::addCodeBlocks(vector < SusCFG * >susCFG)
for (size_t i = 0; i < susCFG.size(); i++) { {
for (unsigned int i = 0; i < susCFG.size(); i++) {
_codeBlockVector.push_back(susCFG.at(i)); _codeBlockVector.push_back(susCFG.at(i));
} }
} }
...@@ -281,7 +282,7 @@ void Transition::dump(raw_ostream & os) ...@@ -281,7 +282,7 @@ void Transition::dump(raw_ostream & os)
getBlockID(); getBlockID();
os << "\n Final State : " << _finalState->returnSusCFGBlock()->getBlockID(); os << "\n Final State : " << _finalState->returnSusCFGBlock()->getBlockID();
os << "\n Transition Blocks : "; os << "\n Transition Blocks : ";
for ( size_t i{0}; i < _codeBlockVector.size(); i++) { for (unsigned int i = 0; i < _codeBlockVector.size(); i++) {
os << _codeBlockVector.at(i)->getBlockID() << " "; os << _codeBlockVector.at(i)->getBlockID() << " ";
} }
} }
...@@ -290,7 +291,7 @@ void Transition::dump(raw_ostream & os) ...@@ -290,7 +291,7 @@ void Transition::dump(raw_ostream & os)
SuspensionAutomata::SuspensionAutomata(vector<WaitContainer*> waitCalls, CXXMethodDecl * d, ASTContext * a, raw_ostream & os):_d(d), _a(a), _os(os) SuspensionAutomata::SuspensionAutomata(vector<WaitContainer*> waitCalls, CXXMethodDecl * d, ASTContext * a, raw_ostream & os):_d(d), _a(a), _os(os)
{ {
for (size_t i{0}; i<waitCalls.size(); i++) { for (int i = 0; i<waitCalls.size(); i++) {
WaitContainer *wc = waitCalls.at(i); WaitContainer *wc = waitCalls.at(i);
_waitCalls.push_back(wc->getASTNode()); _waitCalls.push_back(wc->getASTNode());
} }
...@@ -304,6 +305,7 @@ SuspensionAutomata::~SuspensionAutomata() ...@@ -304,6 +305,7 @@ SuspensionAutomata::~SuspensionAutomata()
bool SuspensionAutomata::initialize() bool SuspensionAutomata::initialize()
{ {
const CFG::BuildOptions & b = CFG::BuildOptions(); const CFG::BuildOptions & b = CFG::BuildOptions();
_cfg = CFG::buildCFG(cast < Decl > (_d), _d->getBody(), _a, b); _cfg = CFG::buildCFG(cast < Decl > (_d), _d->getBody(), _a, b);
if (_cfg != NULL) { if (_cfg != NULL) {
...@@ -325,7 +327,7 @@ bool SuspensionAutomata::isWaitCall(const CFGStmt * cs) ...@@ -325,7 +327,7 @@ bool SuspensionAutomata::isWaitCall(const CFGStmt * cs)
if (!m) { if (!m) {
return f; return f;
} }
for (size_t i{0}; i < _waitCalls.size(); i++) { for (int i = 0; i < _waitCalls.size(); i++) {
CallExpr *ce = _waitCalls.at(i); CallExpr *ce = _waitCalls.at(i);
if (m == ce) { if (m == ce) {
f = true; f = true;
...@@ -363,7 +365,7 @@ void SuspensionAutomata::genSusCFG() ...@@ -363,7 +365,7 @@ void SuspensionAutomata::genSusCFG()
susCFGBlockMapType susCFGBlockMap; susCFGBlockMapType susCFGBlockMap;
// bool isFirstCFGBlockID = false; bool isFirstCFGBlockID = false;
for (CFG::iterator it = _cfg->end() - 1, eit = _cfg->begin(); it != eit; --it) { for (CFG::iterator it = _cfg->end() - 1, eit = _cfg->begin(); it != eit; --it) {
...@@ -389,7 +391,7 @@ void SuspensionAutomata::genSusCFG() ...@@ -389,7 +391,7 @@ void SuspensionAutomata::genSusCFG()
_os << "Dump CFG Block\n"; _os << "Dump CFG Block\n";
b->dump(_cfg, LO, false); b->dump(_cfg, LO, false);
*/ */
// unsigned int prevCFGBlockID; unsigned int prevCFGBlockID;
for (CFGBlock::const_iterator bit = b->begin(), bite = b->end(); for (CFGBlock::const_iterator bit = b->begin(), bite = b->end();
bit != bite; bit++) { bit != bite; bit++) {
...@@ -432,9 +434,10 @@ void SuspensionAutomata::genSusCFG() ...@@ -432,9 +434,10 @@ void SuspensionAutomata::genSusCFG()
CFGBlock *prev = NULL; CFGBlock *prev = NULL;
SusCFG *prevBlock = NULL; SusCFG *prevBlock = NULL;
for (size_t i = 0; i < splitBlocksVector.size(); i++) { for (unsigned int i = 0; i < splitBlocksVector.size(); i++) {
CFGBlock *current = splitBlocksVector.at(i); CFGBlock *current = splitBlocksVector.at(i);
SusCFG *splitBlock = new SusCFG(const_cast < CFGBlock * >(splitBlocksVector.at(i))); SusCFG *splitBlock =
new SusCFG(const_cast < CFGBlock * >(splitBlocksVector.at(i)));
currBlock->addChildBlockList(splitBlock); currBlock->addChildBlockList(splitBlock);
if (current->getLabel()) { if (current->getLabel()) {
splitBlock->setWaitBlock(); splitBlock->setWaitBlock();
...@@ -443,7 +446,7 @@ void SuspensionAutomata::genSusCFG() ...@@ -443,7 +446,7 @@ void SuspensionAutomata::genSusCFG()
if (pre.size() != 0) { if (pre.size() != 0) {
// add trailing statements to post block wait stmt // add trailing statements to post block wait stmt
CFGBlock *newCFGBlock = _cfg->createBlock(); CFGBlock *newCFGBlock = _cfg->createBlock();
for (size_t j = 0; j < pre.size(); j++) { for (unsigned int j = 0; j < pre.size(); j++) {
newCFGBlock->appendStmt(const_cast < Stmt * >(pre.at(j)->getStmt()), newCFGBlock->appendStmt(const_cast < Stmt * >(pre.at(j)->getStmt()),
_cfg->getBumpVectorContext()); _cfg->getBumpVectorContext());
} }
...@@ -570,7 +573,7 @@ void SuspensionAutomata::genSusCFG() ...@@ -570,7 +573,7 @@ void SuspensionAutomata::genSusCFG()
} }
void SuspensionAutomata::addRemainingBlocks(State *initialState, vector<SusCFG*>& transitionBlocks){ void SuspensionAutomata::addRemainingBlocks(State *initialState, vector<SusCFG*>& transitionBlocks){
// bool duplicate = false; bool duplicate = false;
if (_stateCommonCodeBlockMap.find(initialState) != _stateCommonCodeBlockMap.end()) { if (_stateCommonCodeBlockMap.find(initialState) != _stateCommonCodeBlockMap.end()) {
stateCommonCodeBlockMapType::iterator stateFound = _stateCommonCodeBlockMap.find(initialState); stateCommonCodeBlockMapType::iterator stateFound = _stateCommonCodeBlockMap.find(initialState);
checkInsert(stateFound->second, transitionBlocks); checkInsert(stateFound->second, transitionBlocks);
...@@ -590,10 +593,11 @@ vector<SusCFG*> SuspensionAutomata::modifDFS(SusCFG * block, State *initialState ...@@ -590,10 +593,11 @@ vector<SusCFG*> SuspensionAutomata::modifDFS(SusCFG * block, State *initialState
traversedBlocks.pop_front(); traversedBlocks.pop_front();
if (currentBlock->isWaitBlock()) { if (currentBlock->isWaitBlock()) {
float timeInNs{}; float timeInNs;
string eventName{}; string eventName;
isWaitEncounter = true; isWaitEncounter = true;
susCFGStateMapType::iterator stateFound = susCFGStateMap.find(currentBlock); susCFGStateMapType::iterator stateFound =
susCFGStateMap.find(currentBlock);
State *finalState = stateFound->second; State *finalState = stateFound->second;
if (isTimedWait(currentBlock->getWaitStmt())) { if (isTimedWait(currentBlock->getWaitStmt())) {
...@@ -684,10 +688,10 @@ vector<SusCFG*> SuspensionAutomata::modifDFS(SusCFG * block, State *initialState ...@@ -684,10 +688,10 @@ vector<SusCFG*> SuspensionAutomata::modifDFS(SusCFG * block, State *initialState
} }
void SuspensionAutomata::checkInsert(vector<SusCFG*> source, vector<SusCFG*>& target) { void SuspensionAutomata::checkInsert(vector<SusCFG*> source, vector<SusCFG*>& target) {
bool duplicate{false}; bool duplicate;
for (size_t i = 0; i<source.size(); i++) { for (int i = 0; i<source.size(); i++) {
duplicate = false; duplicate = false;
for (size_t j = 0; j<target.size(); j++) { for (int j = 0; j<target.size(); j++) {
if (source.at(i) == target.at(j)) { if (source.at(i) == target.at(j)) {
duplicate = true; duplicate = true;
break; break;
...@@ -703,7 +707,7 @@ void SuspensionAutomata::genSauto() ...@@ -703,7 +707,7 @@ void SuspensionAutomata::genSauto()
{ {
susCFGVectorType susCFGVector = _susCFGVector; susCFGVectorType susCFGVector = _susCFGVector;
susCFGVectorType waitBlocks; susCFGVectorType waitBlocks;
for (size_t i = 0; i < susCFGVector.size(); i++) { for (int i = 0; i < susCFGVector.size(); i++) {
if (susCFGVector.at(i)->isWaitBlock() || i == 0) { if (susCFGVector.at(i)->isWaitBlock() || i == 0) {
waitBlocks.push_back(susCFGVector.at(i)); waitBlocks.push_back(susCFGVector.at(i));
State *state = new State(susCFGVector.at(i), false, false, false, false); State *state = new State(susCFGVector.at(i), false, false, false, false);
...@@ -716,7 +720,7 @@ void SuspensionAutomata::genSauto() ...@@ -716,7 +720,7 @@ void SuspensionAutomata::genSauto()
} }
} }
for (size_t i = 0; i < waitBlocks.size(); i++) { for (int i = 0; i < waitBlocks.size(); i++) {
SusCFG *waitBlock = waitBlocks.at(i); SusCFG *waitBlock = waitBlocks.at(i);
...@@ -726,7 +730,7 @@ void SuspensionAutomata::genSauto() ...@@ -726,7 +730,7 @@ void SuspensionAutomata::genSauto()
State *initialState = stateFound->second; State *initialState = stateFound->second;
vector<SusCFG*> backTrackCodeBlocks; vector<SusCFG*> backTrackCodeBlocks;
//SusCFG* lastBlock; SusCFG* lastBlock;
susCFGSuccIDMap.clear(); // For each new initial state, start fresh... susCFGSuccIDMap.clear(); // For each new initial state, start fresh...
// Left child.. do the same for the right child // Left child.. do the same for the right child
do { do {
...@@ -742,7 +746,7 @@ void SuspensionAutomata::genSauto() ...@@ -742,7 +746,7 @@ void SuspensionAutomata::genSauto()
//_os <<"\n Transition Blocks : "; //_os <<"\n Transition Blocks : ";
backTrackCodeBlocks.clear(); backTrackCodeBlocks.clear();
for (size_t j = 0; j<transitionCodeBlocks.size(); j++) { for (int j = 0; j<transitionCodeBlocks.size(); j++) {
backTrackCodeBlocks.push_back(transitionCodeBlocks.at(j)); backTrackCodeBlocks.push_back(transitionCodeBlocks.at(j));
//_os <<" "<<transitionCodeBlocks.at(j)->getBlockID();; //_os <<" "<<transitionCodeBlocks.at(j)->getBlockID();;
} }
...@@ -819,7 +823,7 @@ bool is_found(Node n1, Node n2) ...@@ -819,7 +823,7 @@ bool is_found(Node n1, Node n2)
template <template <typename, typename> class Container, typename Node, typename Allocator> template <template <typename, typename> class Container, typename Node, typename Allocator>
bool generic_isFound(Container<Node, Allocator> &container, Node node) bool generic_isFound(Container<Node, Allocator> &container, Node node)
{ {
// bool foundBlock = false; bool foundBlock = false;
typename Container<Node, Allocator>::iterator itr = std::find_if( typename Container<Node, Allocator>::iterator itr = std::find_if(
container.begin(), container.begin(),
...@@ -846,7 +850,7 @@ bool SuspensionAutomata::isFound(vector < Transition * >visitedState, ...@@ -846,7 +850,7 @@ bool SuspensionAutomata::isFound(vector < Transition * >visitedState,
float SuspensionAutomata::getTime(Stmt * stmt) float SuspensionAutomata::getTime(Stmt * stmt)
{ {
float factor{}; float factor;
if (CXXMemberCallExpr * ce = dyn_cast < CXXMemberCallExpr > (stmt)) { if (CXXMemberCallExpr * ce = dyn_cast < CXXMemberCallExpr > (stmt)) {
if (getArgumentName(ce->getArg(1)) == "SC_FS") { if (getArgumentName(ce->getArg(1)) == "SC_FS") {
factor = 1000000; factor = 1000000;
...@@ -863,7 +867,6 @@ float SuspensionAutomata::getTime(Stmt * stmt) ...@@ -863,7 +867,6 @@ float SuspensionAutomata::getTime(Stmt * stmt)
} }
return (atof(getArgumentName(ce->getArg(0)).c_str()) * factor); return (atof(getArgumentName(ce->getArg(0)).c_str()) * factor);
} }
return factor;
} }
string SuspensionAutomata::getEvent(Stmt * stmt) string SuspensionAutomata::getEvent(Stmt * stmt)
...@@ -871,8 +874,6 @@ string SuspensionAutomata::getEvent(Stmt * stmt) ...@@ -871,8 +874,6 @@ string SuspensionAutomata::getEvent(Stmt * stmt)
if (CXXMemberCallExpr * ce = dyn_cast < CXXMemberCallExpr > (stmt)) { if (CXXMemberCallExpr * ce = dyn_cast < CXXMemberCallExpr > (stmt)) {
return (getArgumentName(ce->getArg(0))); return (getArgumentName(ce->getArg(0)));
} }
return "Error: NONE";
} }
......
Markdown is supported
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