improved fix_common_blocks
This commit is contained in:
@@ -18,69 +18,66 @@ using std::tuple;
|
||||
|
||||
/// main function:
|
||||
// renew unions for all common blocks in the file
|
||||
static void BuildNewCommDecls(SgFile* file, const map<string, CommonBlock*> allCommonBlocks,
|
||||
map<string, deque<CommConstraint>>& newCommonDecls, map<string, map<string, deque<CommConstraint>>>& commDecls,
|
||||
set<string>& badCommon, map<string, set<string>>& notUsedVars, vector<SgStatement*>& programUnits);
|
||||
//void BuildNewCommDecls
|
||||
|
||||
// get names of variables and array elements, which were referenced in programm unit
|
||||
static set<string> getUses(SgStatement* firstSt, const set<string>& commonVarNames);
|
||||
static void getUsesFromExpr(SgExpression* expr, const set<string>& commonVarNames, set<string>& used);
|
||||
//set<string> getUses
|
||||
//void getUsesFromExpr
|
||||
|
||||
// splits arrays into elements and replaces not used vars with empty constraints
|
||||
static bool splitType(deque<CommConstraint>& d, bool check_use, const set<string>& namesOfUsedVars);
|
||||
//bool splitType
|
||||
|
||||
// create constraits set
|
||||
static deque<CommConstraint> makeConstraints(deque<CommConstraint>& constraints, const set<string>& namesOfUsedVars, set<string>& notUsedVars);
|
||||
//deque<CommConstraint> makeConstraints
|
||||
|
||||
// build union
|
||||
static bool buildConstraintsUnion(deque<CommConstraint>& U, deque<CommConstraint> B, const set<string>& namesOfUsedVars, pair<CommConstraint, CommConstraint>& problemConstraints);
|
||||
static bool docheckUnequalConstraints(deque<CommConstraint>& U, deque<CommConstraint>& B, deque<CommConstraint>& newU, pair<CommConstraint, CommConstraint>& problemConstraints);
|
||||
static bool check(deque<CommConstraint>& A, deque<CommConstraint>& B, pair<CommConstraint, CommConstraint>& problemConstraints);
|
||||
//bool buildConstraintsUnion
|
||||
//bool docheckUnequalConstraints
|
||||
//bool check
|
||||
|
||||
/// small help functions:
|
||||
static string getParentName(const string& name);
|
||||
static bool equalDims(const CommConstraint& a, const CommConstraint& b);
|
||||
static bool equalConstraints(const CommConstraint& a, const CommConstraint& b);
|
||||
static void addElem(deque<CommConstraint>& comm, const CommConstraint& elem);
|
||||
//////
|
||||
//string getParentName
|
||||
//bool equalDims
|
||||
//bool equalConstraints
|
||||
//void addElem
|
||||
|
||||
// change names of variables in 'constraints'
|
||||
static void fixNames(deque<CommConstraint>& constraints, const string& commName);
|
||||
//void fixNames
|
||||
|
||||
////// step2: transformation
|
||||
|
||||
/// main function
|
||||
// peform transformation on every program unit in the file
|
||||
static void fixFunctions(SgFile* file, vector<SgStatement*> programUnits, map<string, deque<CommConstraint>>& newCommonDecls,
|
||||
map<string, map<string, deque<CommConstraint>>>& commDecls, const set<string>& badCommon, map<string, set<string>>& notUsedVars);
|
||||
//void fixFunctions
|
||||
|
||||
// get pairs of names (namesOldToNew) for renaming
|
||||
static bool getNamesOldToNew(deque<CommConstraint> newDecl, deque<CommConstraint> oldDecl, map<string, string>& namesOldToNew);
|
||||
//bool getNamesOldToNew
|
||||
|
||||
// create new symbols for new variables in new common declaration (constraints)
|
||||
static void makeCommVarSymbs(const deque<CommConstraint>& constraints, SgFile* file, SgStatement* func, string commName,
|
||||
map<string, SgSymbol*>& symbs, vector<SgSymbol*>& needNewDecl);
|
||||
//void makeCommVarSymbs
|
||||
|
||||
// delete from program unit all references to names in commVarNames
|
||||
static void deleteOldVars(SgStatement* firstSt, const set<string>& commVarNames);
|
||||
//void deleteOldVars
|
||||
|
||||
// calls fixExpression for each statement, replaces names in data statement
|
||||
static void renameVariables(SgStatement* firstSt, const map<string, SgSymbol*>& newVarSymbs, const map<string, string>& namesOldToNew);
|
||||
//void renameVariables
|
||||
|
||||
// replacing variables or array elements in expression expr if their names are in namesOldToNew
|
||||
static SgExpression* fixExpression(SgExpression* expr, const map<string, SgSymbol*>& newSymbs, const map<string, string>& namesOldToNew);
|
||||
//SgExpression* fixExpression
|
||||
|
||||
// make new exprList exprssion for new declaration decl with symbols from newSymbs
|
||||
static SgExpression* makeExprListForCommon(const deque<CommConstraint>& decl, const map<string, SgSymbol*>& newSymbs,
|
||||
SgFile* file, SgStatement* firstSt);
|
||||
//SgExpression* makeExprListForCommon
|
||||
|
||||
// replace old common declarations with new ones
|
||||
static void rewriteCommon(SgStatement* firstSt, map<string, SgExpression*>& commListExprs);
|
||||
//void rewriteCommon
|
||||
|
||||
/// help functions:
|
||||
static SgExpression* makeIdxFromStr(const string& str);
|
||||
//SgExpression* makeIdxFromStr(const string& str);
|
||||
|
||||
// make new expression of array element
|
||||
static SgExpression* newArrElemExpr(const string& newName, const map<string, SgSymbol*>& newSymbs);
|
||||
static bool variablePositionComp(const Variable* lhs, const Variable* rhs);
|
||||
//SgExpression* newArrElemExpr
|
||||
//bool variablePositionComp
|
||||
//////
|
||||
|
||||
|
||||
|
||||
CommConstraint::CommConstraint(const Variable* var, bool u, const string& funcName, const string& fileName)
|
||||
{
|
||||
used = u;
|
||||
@@ -125,7 +122,6 @@ CommConstraint::CommConstraint(const Variable* var, bool u, const string& funcNa
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CommConstraint::CommConstraint(const string& name, SgType* t, bool u) : used(u), type(t), identifier(name)
|
||||
{
|
||||
typeVariant = type->variant();
|
||||
@@ -139,8 +135,7 @@ CommConstraint::CommConstraint(const string& name, SgType* t, bool u, vector<Dec
|
||||
size = getSizeOfType(type);
|
||||
}
|
||||
|
||||
|
||||
string getParentName(const string& name)
|
||||
static string getParentName(const string& name)
|
||||
{
|
||||
size_t len = name.find("%");
|
||||
size_t posB = name.find("(");
|
||||
@@ -154,8 +149,7 @@ string getParentName(const string& name)
|
||||
return name.substr(0, len);
|
||||
}
|
||||
|
||||
|
||||
void getUsesFromExpr(SgExpression* expr, const set<string>& commonVarNames, set<string>& used)
|
||||
static void getUsesFromExpr(SgExpression* expr, const set<string>& commonVarNames, set<string>& used)
|
||||
{
|
||||
if (expr == NULL)
|
||||
return;
|
||||
@@ -194,8 +188,7 @@ void getUsesFromExpr(SgExpression* expr, const set<string>& commonVarNames, set<
|
||||
getUsesFromExpr(expr->rhs(), commonVarNames, used);
|
||||
}
|
||||
|
||||
|
||||
set<string> getUses(SgStatement* firstSt, const set<string>& commonVarNames)
|
||||
static set<string> getUses(SgStatement* firstSt, const set<string>& commonVarNames)
|
||||
{
|
||||
set<string> used;
|
||||
SgStatement* lastSt = firstSt->lastNodeOfStmt();
|
||||
@@ -212,8 +205,7 @@ set<string> getUses(SgStatement* firstSt, const set<string>& commonVarNames)
|
||||
return used;
|
||||
}
|
||||
|
||||
|
||||
bool equalDims(const CommConstraint& a, const CommConstraint& b)
|
||||
static bool equalDims(const CommConstraint& a, const CommConstraint& b)
|
||||
{
|
||||
const vector<pair<int, int>>& adim = a.arrayInfo->GetSizes();
|
||||
const vector<pair<int, int>>& bdim = b.arrayInfo->GetSizes();
|
||||
@@ -228,9 +220,8 @@ bool equalDims(const CommConstraint& a, const CommConstraint& b)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// TODO: add attributes to CommConstraints, check if a and b have equal attributes
|
||||
bool equalConstraints(const CommConstraint& a, const CommConstraint& b)
|
||||
static bool equalConstraints(const CommConstraint& a, const CommConstraint& b)
|
||||
{
|
||||
if ((a.arrayInfo != NULL && b.arrayInfo == NULL) || ((a.arrayInfo == NULL && b.arrayInfo != NULL)))
|
||||
return false;
|
||||
@@ -241,8 +232,7 @@ bool equalConstraints(const CommConstraint& a, const CommConstraint& b)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void addElem(deque<CommConstraint>& comm, const CommConstraint& elem)
|
||||
static void addElem(deque<CommConstraint>& comm, const CommConstraint& elem)
|
||||
{
|
||||
if (elem.typeVariant == 0 && !comm.empty() && comm.back().typeVariant == 0)
|
||||
comm.back().size += elem.size;
|
||||
@@ -250,9 +240,8 @@ void addElem(deque<CommConstraint>& comm, const CommConstraint& elem)
|
||||
comm.push_back(elem);
|
||||
}
|
||||
|
||||
|
||||
// TODO: check attributes: do not split arrays with pointer or target attributes if check_use == true
|
||||
bool splitType(deque<CommConstraint>& d, bool check_use, const set<string>& namesOfUsedVars = {})
|
||||
static bool splitType(deque<CommConstraint>& d, bool check_use, const set<string>& namesOfUsedVars = {})
|
||||
{
|
||||
CommConstraint var = d.front();
|
||||
string name = var.identifier;
|
||||
@@ -300,8 +289,7 @@ bool splitType(deque<CommConstraint>& d, bool check_use, const set<string>& name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
deque<CommConstraint> makeConstraints(deque<CommConstraint>& constraints, const set<string>& namesOfUsedVars, set<string>& notUsedVars)
|
||||
static deque<CommConstraint> makeConstraints(deque<CommConstraint>& constraints, const set<string>& namesOfUsedVars, set<string>& notUsedVars)
|
||||
{
|
||||
deque<CommConstraint> res;
|
||||
while (!constraints.empty())
|
||||
@@ -318,8 +306,7 @@ deque<CommConstraint> makeConstraints(deque<CommConstraint>& constraints, const
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool check(deque<CommConstraint>& A, deque<CommConstraint>& B, pair<CommConstraint, CommConstraint>& problemConstraints)
|
||||
static bool check(deque<CommConstraint>& A, deque<CommConstraint>& B, pair<CommConstraint, CommConstraint>& problemConstraints)
|
||||
{
|
||||
while (!A.empty() && !B.empty())
|
||||
{
|
||||
@@ -358,8 +345,8 @@ bool check(deque<CommConstraint>& A, deque<CommConstraint>& B, pair<CommConstrai
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool docheckUnequalConstraints(deque<CommConstraint>& U, deque<CommConstraint>& B, deque<CommConstraint>& newU, pair<CommConstraint, CommConstraint>& problemConstraints)
|
||||
static bool docheckUnequalConstraints(deque<CommConstraint>& U, deque<CommConstraint>& B, deque<CommConstraint>& newU,
|
||||
pair<CommConstraint, CommConstraint>& problemConstraints)
|
||||
{
|
||||
if (U.front().typeVariant == 0)
|
||||
{
|
||||
@@ -382,8 +369,8 @@ bool docheckUnequalConstraints(deque<CommConstraint>& U, deque<CommConstraint>&
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool buildConstraintsUnion(deque<CommConstraint>& U, deque<CommConstraint> B, const set<string>& namesOfUsedVars, pair<CommConstraint, CommConstraint>& problemConstraints)
|
||||
static bool buildConstraintsUnion(deque<CommConstraint>& U, deque<CommConstraint> B,
|
||||
const set<string>& namesOfUsedVars, pair<CommConstraint, CommConstraint>& problemConstraints)
|
||||
{
|
||||
deque<CommConstraint> newU;
|
||||
while (!U.empty() && !B.empty())
|
||||
@@ -438,8 +425,8 @@ bool buildConstraintsUnion(deque<CommConstraint>& U, deque<CommConstraint> B, co
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool getNamesOldToNew(deque<CommConstraint> newDecl, deque<CommConstraint> oldDecl, map<string, string>& namesOldToNew)
|
||||
//TODO: check this: newDecl and oldDecl => do these variables need references?
|
||||
static bool getNamesOldToNew(deque<CommConstraint> newDecl, deque<CommConstraint> oldDecl, map<string, string>& namesOldToNew)
|
||||
{
|
||||
bool needChange = false;
|
||||
map<string, string> rename;
|
||||
@@ -504,16 +491,18 @@ bool getNamesOldToNew(deque<CommConstraint> newDecl, deque<CommConstraint> oldDe
|
||||
newDecl.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
if (!oldDecl.empty() || !newDecl.empty())
|
||||
needChange = true;
|
||||
|
||||
if (needChange)
|
||||
namesOldToNew.insert(rename.begin(), rename.end());
|
||||
|
||||
return needChange;
|
||||
}
|
||||
|
||||
|
||||
void makeCommVarSymbs(const deque<CommConstraint>& constraints, SgFile* file, SgStatement* func, string commName,
|
||||
map<string, SgSymbol*>& symbs, vector<SgSymbol*>& needNewDecl)
|
||||
static void makeCommVarSymbs(const deque<CommConstraint>& constraints, SgFile* file, SgStatement* func, const string& commName,
|
||||
map<string, SgSymbol*>& symbs, vector<SgSymbol*>& needNewDecl)
|
||||
{
|
||||
for (const CommConstraint& var : constraints)
|
||||
{
|
||||
@@ -526,8 +515,7 @@ void makeCommVarSymbs(const deque<CommConstraint>& constraints, SgFile* file, Sg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void deleteOldVars(SgStatement* firstSt, const set<string>& commVarNames)
|
||||
static void deleteOldVars(SgStatement* firstSt, const set<string>& commVarNames)
|
||||
{
|
||||
SgStatement* lastSt = firstSt->lastNodeOfStmt();
|
||||
vector<SgStatement*> stmtsToDelete;
|
||||
@@ -573,12 +561,12 @@ void deleteOldVars(SgStatement* firstSt, const set<string>& commVarNames)
|
||||
}
|
||||
// TODO: delete common variables form attributes statements (like DIM_STAT)
|
||||
}
|
||||
|
||||
for (SgStatement* st : stmtsToDelete)
|
||||
st->deleteStmt();
|
||||
}
|
||||
|
||||
|
||||
SgExpression* makeIdxFromStr(const string& str)
|
||||
static SgExpression* makeIdxFromStr(const string& str)
|
||||
{
|
||||
vector<SgExpression*> items;
|
||||
int num = 0;
|
||||
@@ -593,13 +581,13 @@ SgExpression* makeIdxFromStr(const string& str)
|
||||
num = 0;
|
||||
}
|
||||
}
|
||||
|
||||
reverse(items.begin(), items.end());
|
||||
SgExpression* exprList = makeExprList(items, false);
|
||||
return exprList;
|
||||
}
|
||||
|
||||
|
||||
SgExpression* newArrElemExpr(const string& newName, const map<string, SgSymbol*>& newSymbs)
|
||||
static SgExpression* newArrElemExpr(const string& newName, const map<string, SgSymbol*>& newSymbs)
|
||||
{
|
||||
size_t pos = newName.find('(');
|
||||
SgExpression* newExpr = new SgArrayRefExp(*newSymbs.at(newName.substr(0, pos)));
|
||||
@@ -607,11 +595,11 @@ SgExpression* newArrElemExpr(const string& newName, const map<string, SgSymbol*>
|
||||
return newExpr;
|
||||
}
|
||||
|
||||
|
||||
SgExpression* fixExpression(SgExpression* expr, const map<string, SgSymbol*>& newSymbs, const map<string, string>& namesOldToNew)
|
||||
static SgExpression* fixExpression(SgExpression* expr, const map<string, SgSymbol*>& newSymbs, const map<string, string>& namesOldToNew)
|
||||
{
|
||||
if (expr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (expr->variant() == VAR_REF || expr->variant() == ARRAY_REF)
|
||||
{
|
||||
string name = expr->symbol()->identifier();
|
||||
@@ -647,17 +635,18 @@ SgExpression* fixExpression(SgExpression* expr, const map<string, SgSymbol*>& ne
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SgExpression* lhs = fixExpression(expr->lhs(), newSymbs, namesOldToNew);
|
||||
if (lhs != NULL)
|
||||
expr->setLhs(lhs);
|
||||
|
||||
SgExpression* rhs = fixExpression(expr->rhs(), newSymbs, namesOldToNew);
|
||||
if (rhs != NULL)
|
||||
expr->setRhs(rhs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void renameVariables(SgStatement* firstSt, const map<string, SgSymbol*>& newVarSymbs, const map<string, string>& namesOldToNew)
|
||||
static void renameVariables(SgStatement* firstSt, const map<string, SgSymbol*>& newVarSymbs, const map<string, string>& namesOldToNew)
|
||||
{
|
||||
SgStatement* lastSt = firstSt->lastNodeOfStmt();
|
||||
for (SgStatement* curSt = firstSt; curSt != NULL && curSt != lastSt; curSt = curSt->lexNext())
|
||||
@@ -705,8 +694,7 @@ void renameVariables(SgStatement* firstSt, const map<string, SgSymbol*>& newVarS
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SgExpression* makeExprListForCommon(const deque<CommConstraint>& decl, const map<string, SgSymbol*>& newSymbs,
|
||||
static SgExpression* makeExprListForCommon(const deque<CommConstraint>& decl, const map<string, SgSymbol*>& newSymbs,
|
||||
SgFile* file, SgStatement* firstSt)
|
||||
{
|
||||
vector<SgExpression*> items;
|
||||
@@ -740,8 +728,7 @@ SgExpression* makeExprListForCommon(const deque<CommConstraint>& decl, const map
|
||||
return exprList;
|
||||
}
|
||||
|
||||
|
||||
void rewriteCommon(SgStatement* firstSt, map<string, SgExpression*>& commListExprs)
|
||||
static void rewriteCommon(SgStatement* firstSt, map<string, SgExpression*>& commListExprs)
|
||||
{
|
||||
vector<SgStatement*> commonStmtsToDelete;
|
||||
for (SgStatement* st = firstSt; st != firstSt->lastDeclaration()->lexNext(); st = st->lexNext())
|
||||
@@ -792,12 +779,12 @@ void rewriteCommon(SgStatement* firstSt, map<string, SgExpression*>& commListExp
|
||||
commonStmtsToDelete.push_back(st);
|
||||
}
|
||||
}
|
||||
|
||||
for (SgStatement* st : commonStmtsToDelete)
|
||||
st->deleteStmt();
|
||||
}
|
||||
|
||||
|
||||
void fixNames(deque<CommConstraint>& constraints, const string& commName)
|
||||
static void fixNames(deque<CommConstraint>& constraints, const string& commName)
|
||||
{
|
||||
for (auto& var : constraints)
|
||||
{
|
||||
@@ -812,26 +799,26 @@ void fixNames(deque<CommConstraint>& constraints, const string& commName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool variablePositionComp(const Variable* lhs, const Variable* rhs)
|
||||
static bool variablePositionComp(const Variable* lhs, const Variable* rhs)
|
||||
{
|
||||
return lhs->getPosition() < rhs->getPosition();
|
||||
}
|
||||
|
||||
|
||||
void fixFunctions(SgFile* file, vector<SgStatement*> programUnits, map<string, deque<CommConstraint>>& newCommonDecls,
|
||||
map<string, map<string, deque<CommConstraint>>>& commDecls, const set<string>& badCommon, map<string, set<string>>& notUsedVars)
|
||||
static void fixFunctions(SgFile* file, const vector<SgStatement*>& programUnits, map<string, deque<CommConstraint>>& newCommonDecls,
|
||||
map<string, map<string, deque<CommConstraint>>>& commDecls, const set<string>& badCommon, map<string, set<string>>& notUsedVars)
|
||||
{
|
||||
for (SgStatement* unitSt : programUnits)
|
||||
{
|
||||
string funcName = unitSt->symbol()->identifier();
|
||||
if (commDecls.find(funcName) == commDecls.end())
|
||||
continue;
|
||||
|
||||
SgStatement* firstSt = unitSt;
|
||||
map<string, SgExpression*> commListExprs;
|
||||
map<string, SgSymbol*> newVarSymbs; // new symbols for new variables
|
||||
map<string, string> namesOldToNew; // for ranaming: old name -> new name
|
||||
vector<SgSymbol*> needNewDecl;
|
||||
|
||||
for (auto& common : commDecls[funcName])
|
||||
{
|
||||
string commName = common.first;
|
||||
@@ -842,9 +829,11 @@ void fixFunctions(SgFile* file, vector<SgStatement*> programUnits, map<string, d
|
||||
bool needChange = getNamesOldToNew(newDecl, common.second, namesOldToNew);
|
||||
if (!needChange)
|
||||
continue;
|
||||
|
||||
makeCommVarSymbs(newDecl, file, firstSt, commName, newVarSymbs, needNewDecl);
|
||||
commListExprs[commName] = makeExprListForCommon(newDecl, newVarSymbs, file, firstSt);
|
||||
}
|
||||
|
||||
if (!commListExprs.empty())
|
||||
{
|
||||
for (const auto& item : commListExprs)
|
||||
@@ -858,10 +847,9 @@ void fixFunctions(SgFile* file, vector<SgStatement*> programUnits, map<string, d
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BuildNewCommDecls(SgFile* file, const map<string, CommonBlock*> allCommonBlocks,
|
||||
map<string, deque<CommConstraint>>& newCommonDecls, map<string, map<string, deque<CommConstraint>>>& commDecls,
|
||||
set<string>& badCommon, map<string, set<string>>& notUsedVars, vector<SgStatement*>& programUnits)
|
||||
static void buildNewCommDecls(SgFile* file, const map<string, CommonBlock*>& allCommonBlocks,
|
||||
map<string, deque<CommConstraint>>& newCommonDecls, map<string, map<string, deque<CommConstraint>>>& commDecls,
|
||||
set<string>& badCommon, map<string, set<string>>& notUsedVars, vector<SgStatement*>& programUnits)
|
||||
{
|
||||
string fileName = file->filename();
|
||||
SgStatement* curSt = file->firstStatement();
|
||||
@@ -900,7 +888,8 @@ void BuildNewCommDecls(SgFile* file, const map<string, CommonBlock*> allCommonBl
|
||||
constraints.push_back(newConstr);
|
||||
}
|
||||
if (hasChar && hasNotChar) // TDOO: make proper warning message or separate such common blocks
|
||||
__spf_print(1, "common block '%s' ('%s':%d) contains variables of symbolic and numeric types. It is required to divide\n", commName.c_str(), fileName.c_str(), constraints.back().uses.back().lineNum);
|
||||
__spf_print(1, "common block '%s' ('%s':%d) contains variables of symbolic and numeric types. It is required to divide\n",
|
||||
commName.c_str(), fileName.c_str(), constraints.back().uses.back().getLineNum());
|
||||
if (hasChar)
|
||||
{
|
||||
badCommon.insert(commName);
|
||||
@@ -917,7 +906,7 @@ void BuildNewCommDecls(SgFile* file, const map<string, CommonBlock*> allCommonBl
|
||||
for (auto x : problemConstraints.first.uses) // TODO: make proper warning message
|
||||
for (auto y : problemConstraints.second.uses)
|
||||
__spf_print(1, "variables '%s' and '%s' in one storage association (common block '%s') have different types (files - %s:%d and %s:%d)\n",
|
||||
x.varName.c_str(), y.varName.c_str(), commName.c_str(), x.fileName.c_str(), x.lineNum, y.fileName.c_str(), y.lineNum);
|
||||
x.getVarName(), y.getVarName(), commName.c_str(), x.getFileName(), x.getLineNum(), y.getFileName(), y.getLineNum());
|
||||
}
|
||||
}
|
||||
curSt = curSt->lastNodeOfStmt();
|
||||
@@ -929,7 +918,7 @@ void BuildNewCommDecls(SgFile* file, const map<string, CommonBlock*> allCommonBl
|
||||
|
||||
|
||||
// main function
|
||||
void fixCommonBlocks(const map<string, vector<FuncInfo*>> allFuncInfo, const map<string, CommonBlock*> allCommonBlocks, SgProject* project) // TODO: separate into 2 steps?
|
||||
void fixCommonBlocks(const map<string, vector<FuncInfo*>>& allFuncInfo, const map<string, CommonBlock*>& allCommonBlocks, SgProject* project) // TODO: separate into 2 steps?
|
||||
{
|
||||
int filesNum = project->numberOfFiles();
|
||||
map<string, map<string, map<string, deque<CommConstraint>>>> commDecls; // file_name -> function_name -> common block name -> old declaration of common block
|
||||
@@ -943,10 +932,12 @@ void fixCommonBlocks(const map<string, vector<FuncInfo*>> allFuncInfo, const map
|
||||
SgFile* file = &project->file(i);
|
||||
string fileName = file->filename();
|
||||
file->switchToFile(fileName);
|
||||
BuildNewCommDecls(file, allCommonBlocks, newCommonDecls, commDecls[fileName], badCommon, notUsedVars, programUnitsInFile[fileName]);
|
||||
buildNewCommDecls(file, allCommonBlocks, newCommonDecls, commDecls[fileName], badCommon, notUsedVars, programUnitsInFile[fileName]);
|
||||
}
|
||||
|
||||
for (auto& elem : newCommonDecls)
|
||||
fixNames(elem.second, elem.first);
|
||||
|
||||
for (int i = 0; i < filesNum; i++) // second step
|
||||
{
|
||||
SgFile* file = &project->file(i);
|
||||
|
||||
@@ -16,12 +16,18 @@
|
||||
|
||||
struct DeclInfo // for error messages
|
||||
{
|
||||
private:
|
||||
std::string varName;
|
||||
std::string fileName;
|
||||
int lineNum;
|
||||
|
||||
public:
|
||||
DeclInfo() : varName(""), fileName(""), lineNum(0) {};
|
||||
DeclInfo(const std::string& vn, const std::string& fn, int ln) : varName(vn), fileName(fn), lineNum(ln) {};
|
||||
|
||||
const char* getVarName() const { return varName.c_str(); }
|
||||
const char* getFileName() const { return fileName.c_str(); }
|
||||
int getLineNum() const { return lineNum; }
|
||||
};
|
||||
|
||||
struct CommConstraint // TODO: add variable attributes
|
||||
@@ -42,4 +48,4 @@ struct CommConstraint // TODO: add variable attributes
|
||||
};
|
||||
|
||||
|
||||
void fixCommonBlocks(const std::map<std::string, std::vector<FuncInfo*>> allFuncInfo, const std::map<std::string, CommonBlock*> allCommonBlocks, SgProject* project);
|
||||
void fixCommonBlocks(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo, const std::map<std::string, CommonBlock*>& allCommonBlocks, SgProject* project);
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2464"
|
||||
#define VERSION_SPF "2465"
|
||||
|
||||
Reference in New Issue
Block a user