fixed getNameInLocation
This commit is contained in:
@@ -343,9 +343,9 @@ const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
|
||||
return symbs;
|
||||
}
|
||||
|
||||
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
|
||||
static void findSymbol(SgStatement* func, const string& varName, const string& locName,
|
||||
map<string, SgSymbol*>& altNames)
|
||||
{
|
||||
map<string, SgSymbol*> altNames;
|
||||
for (const auto& s : getModuleSymbols(func))
|
||||
{
|
||||
SgSymbol* orig = OriginalSymbol(s);
|
||||
@@ -353,11 +353,22 @@ SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const stri
|
||||
if (orig->identifier() == varName && orig->scope()->symbol()->identifier() == locName)
|
||||
altNames[s->identifier()] = s;
|
||||
}
|
||||
}
|
||||
|
||||
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)
|
||||
{
|
||||
const string clearName = correctSymbolModuleName(varName);
|
||||
|
||||
map<string, SgSymbol*> altNames;
|
||||
findSymbol(func, varName, locName, altNames);
|
||||
|
||||
if (altNames.size() == 0 && clearName != varName)
|
||||
findSymbol(func, clearName, locName, altNames);
|
||||
|
||||
if (altNames.size() > 0)
|
||||
return altNames.begin()->second;
|
||||
else {
|
||||
__spf_print(1, "%s %s %s\n", func->symbol()->identifier(), varName.c_str(), locName.c_str());
|
||||
__spf_print(1, "%s (%s %s) %s\n", func->symbol()->identifier(), clearName.c_str(), varName.c_str(), locName.c_str());
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
}
|
||||
|
||||
@@ -393,6 +404,15 @@ SgSymbol* getNameInLocation(SgSymbol* curr, SgStatement* location)
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
string correctSymbolModuleName(const string& origFull)
|
||||
{
|
||||
auto it = origFull.find("::");
|
||||
if (it == string::npos)
|
||||
return origFull;
|
||||
else
|
||||
return origFull.substr(it + 2);
|
||||
}
|
||||
|
||||
namespace Distribution
|
||||
{
|
||||
const string Array::GetNameInLocation(void* location_p) const
|
||||
|
||||
Reference in New Issue
Block a user