fixed module symbols analysis
This commit is contained in:
@@ -293,35 +293,45 @@ static SgStatement* findModWithName(const vector<SgStatement*>& modules, const s
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static map<SgStatement*, set<SgSymbol*>> symbolsForFunc;
|
||||
static map<string, set<SgSymbol*>> symbolsForFunc;
|
||||
static set<string> allFiles;
|
||||
|
||||
static void getModuleSymbols(SgStatement* func, set<SgSymbol*>& symbs)
|
||||
{
|
||||
SgSymbol* s = func->symbol()->next();
|
||||
string currScope = func->symbol()->identifier();
|
||||
|
||||
auto it = symbolsForFunc.find(currScope);
|
||||
if (it != symbolsForFunc.end()) {
|
||||
for (const auto& s : it->second)
|
||||
symbs.insert(s);
|
||||
return;
|
||||
}
|
||||
|
||||
SgSymbol* s = func->symbol()->next();
|
||||
while (s)
|
||||
{
|
||||
if (s->scope() == func && IS_BY_USE(s))
|
||||
if (IS_BY_USE(s) && s->scope()->symbol()->identifier() == currScope)
|
||||
symbs.insert(s);
|
||||
s = s->next();
|
||||
}
|
||||
}
|
||||
|
||||
const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
|
||||
const const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
|
||||
{
|
||||
if (symbolsForFunc.find(func) != symbolsForFunc.end())
|
||||
return symbolsForFunc[func];
|
||||
auto it = symbolsForFunc.find(func->symbol()->identifier());
|
||||
if (it != symbolsForFunc.end())
|
||||
return it->second;
|
||||
|
||||
set<SgSymbol*> symbs;
|
||||
getModuleSymbols(func, symbs);
|
||||
|
||||
//if function in contains
|
||||
func = func->controlParent();
|
||||
if (isSgProgHedrStmt(func))
|
||||
getModuleSymbols(func, symbs);
|
||||
auto cp = func->controlParent();
|
||||
if (isSgProgHedrStmt(cp))
|
||||
getModuleSymbols(cp, symbs);
|
||||
|
||||
symbolsForFunc[func] = symbs;
|
||||
return symbolsForFunc[func];
|
||||
symbolsForFunc[func->symbol()->identifier()] = symbs;
|
||||
return symbs;
|
||||
}
|
||||
|
||||
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
|
||||
|
||||
Reference in New Issue
Block a user