moved SPF_GetIncludeDependencies to json
This commit is contained in:
@@ -331,7 +331,7 @@ static string unparseProjectIfNeed(SgFile* file, const int curr_regime, const bo
|
||||
unparseToBuf = removeIncludeStatsAndUnparse(file, file_name, fout_name.c_str(), allIncludeFiles, out_free_form == 1, moduleUsesByFile,
|
||||
moduleDecls, getObjectForFileFromMap(file_name, exctactedModuleStats), toString, false, true);
|
||||
auto itI = filesToInclude.find(file_name);
|
||||
for (auto& incl : itI->second)
|
||||
for (auto& [_, incl] : itI->second)
|
||||
if (allIncludeFiles.find(incl) != allIncludeFiles.end())
|
||||
allIncludeFiles.erase(incl);
|
||||
}
|
||||
@@ -827,20 +827,27 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
auto fileIt = includeDependencies.find(file_name);
|
||||
if (fileIt == includeDependencies.end())
|
||||
fileIt = includeDependencies.insert(fileIt, make_pair(file_name, set<string>()));
|
||||
fileIt = includeDependencies.insert(fileIt, make_pair(file_name, vector<pair<int, string>>()));
|
||||
|
||||
set<string> modFiles;
|
||||
for (auto& elem : moduleDecls)
|
||||
modFiles.insert(elem.second);
|
||||
|
||||
for (SgStatement *first = file->firstStatement(); first; first = first->lexNext())
|
||||
SgStatement* lastFromFile = NULL;
|
||||
for (SgStatement *st = file->firstStatement(); st; st = st->lexNext())
|
||||
{
|
||||
if (strcmp(file_name, first->fileName()))
|
||||
if (st->variant() == MODULE_STMT && modFiles.find(st->fileName()) != modFiles.end())
|
||||
st = st->lastNodeOfStmt();
|
||||
else
|
||||
{
|
||||
if (first->variant() == MODULE_STMT && modFiles.find(first->fileName()) != modFiles.end())
|
||||
first = first->lastNodeOfStmt();
|
||||
if (strcmp(file_name, st->fileName()))
|
||||
{
|
||||
if (lastFromFile == NULL)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
fileIt->second.push_back(make_pair(lastFromFile->lineNumber(), st->fileName()));
|
||||
}
|
||||
else
|
||||
fileIt->second.insert(first->fileName());
|
||||
lastFromFile = st;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1596,9 +1603,9 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
set<string> includedToThisFile;
|
||||
if (itDep != includeDependencies.end())
|
||||
{
|
||||
for (auto &inclDep : itDep->second)
|
||||
for (auto& [_, incl] : itDep->second)
|
||||
{
|
||||
auto comm = commentsToInclude.find(inclDep);
|
||||
auto comm = commentsToInclude.find(incl);
|
||||
if (comm != commentsToInclude.end())
|
||||
for (auto &allComm : comm->second)
|
||||
includedToThisFile.insert(allComm.second.begin(), allComm.second.end());
|
||||
|
||||
Reference in New Issue
Block a user