fixed module analysis

This commit is contained in:
ALEXks
2025-03-05 12:31:01 +03:00
committed by Dudarenko
parent 26fe1d3f61
commit 90894a4723
3 changed files with 24 additions and 18 deletions

View File

@@ -296,12 +296,8 @@ static SgStatement* findModWithName(const vector<SgStatement*>& modules, const s
static map<SgStatement*, set<SgSymbol*>> symbolsForFunc; static map<SgStatement*, set<SgSymbol*>> symbolsForFunc;
static set<string> allFiles; static set<string> allFiles;
static const set<SgSymbol*>& getModeulSymbols(SgStatement *func) static void getModuleSymbols(SgStatement* func, set<SgSymbol*>& symbs)
{ {
if (symbolsForFunc.find(func) != symbolsForFunc.end())
return symbolsForFunc[func];
set<SgSymbol*> symbs;
SgSymbol* s = func->symbol()->next(); SgSymbol* s = func->symbol()->next();
while (s) while (s)
{ {
@@ -309,6 +305,20 @@ static const set<SgSymbol*>& getModeulSymbols(SgStatement *func)
symbs.insert(s); symbs.insert(s);
s = s->next(); s = s->next();
} }
}
static const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
{
if (symbolsForFunc.find(func) != symbolsForFunc.end())
return symbolsForFunc[func];
set<SgSymbol*> symbs;
getModuleSymbols(func, symbs);
//if function in contains
func = func->controlParent();
if (isSgProgHedrStmt(func))
getModuleSymbols(func, symbs);
symbolsForFunc[func] = symbs; symbolsForFunc[func] = symbs;
return symbolsForFunc[func]; return symbolsForFunc[func];
@@ -317,17 +327,13 @@ static const set<SgSymbol*>& getModeulSymbols(SgStatement *func)
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName) SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
{ {
map<string, SgSymbol*> altNames; map<string, SgSymbol*> altNames;
for (const auto& s : getModeulSymbols(func)) for (const auto& s : getModuleSymbols(func))
{ {
SgSymbol* orig = OriginalSymbol(s); SgSymbol* orig = OriginalSymbol(s);
//any suitable symbol can be used
if (orig->identifier() == varName && orig->scope()->symbol()->identifier() == locName) if (orig->identifier() == varName && orig->scope()->symbol()->identifier() == locName)
{
if (altNames.count(s->identifier()))
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
altNames[s->identifier()] = s; altNames[s->identifier()] = s;
} }
}
if (altNames.size() > 0) if (altNames.size() > 0)
return altNames.begin()->second; return altNames.begin()->second;

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2393" #define VERSION_SPF "2394"