fixed BUILD_INCLUDE_DEPENDENCIES pass
This commit is contained in:
@@ -331,7 +331,8 @@ 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& [_, incls] : itI->second)
|
||||
for (auto& incl : incls)
|
||||
if (allIncludeFiles.find(incl) != allIncludeFiles.end())
|
||||
allIncludeFiles.erase(incl);
|
||||
}
|
||||
@@ -827,7 +828,7 @@ 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, vector<pair<int, string>>()));
|
||||
fileIt = includeDependencies.insert(fileIt, make_pair(file_name, map<int, set<string>>()));
|
||||
|
||||
set<string> modFiles;
|
||||
for (auto& elem : moduleDecls)
|
||||
@@ -844,7 +845,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
{
|
||||
if (lastFromFile == NULL)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
fileIt->second.push_back(make_pair(lastFromFile->lineNumber(), st->fileName()));
|
||||
fileIt->second[lastFromFile->lineNumber()].insert(st->fileName());
|
||||
}
|
||||
else
|
||||
lastFromFile = st;
|
||||
@@ -1603,14 +1604,17 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
||||
set<string> includedToThisFile;
|
||||
if (itDep != includeDependencies.end())
|
||||
{
|
||||
for (auto& [_, incl] : itDep->second)
|
||||
for (auto& [_, incls] : itDep->second)
|
||||
{
|
||||
for (auto& incl : incls)
|
||||
{
|
||||
auto comm = commentsToInclude.find(incl);
|
||||
if (comm != commentsToInclude.end())
|
||||
for (auto &allComm : comm->second)
|
||||
for (auto& allComm : comm->second)
|
||||
includedToThisFile.insert(allComm.second.begin(), allComm.second.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = 0; z < parallelRegions.size(); ++z)
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ std::map<std::string, std::map<int, std::set<std::string>>> commentsToInclude;
|
||||
//
|
||||
|
||||
//for INSERT_INCLUDES
|
||||
std::map<std::string, std::vector<std::pair<int, std::string>>> filesToInclude; // file -> includes [nearest line, include]
|
||||
std::map<std::string, std::map<int, std::set<std::string>>> filesToInclude; // file -> includes [nearest line, include]
|
||||
//
|
||||
|
||||
//for PASSES DEPENDENSIES
|
||||
@@ -96,7 +96,7 @@ std::set<passes> passesIgnoreStateDone;
|
||||
//for files info
|
||||
std::map<std::string, int> lineInfo; // file -> lines count
|
||||
std::map<std::string, std::pair<std::set<int>, std::set<int>>> dirsInfo; // file -> dirs <lines SPF, lines DVM> count
|
||||
std::map<std::string, std::vector<std::pair<int, std::string>>> includeDependencies; // file -> includes [nearest line, include]
|
||||
std::map<std::string, std::map<int, std::set<std::string>>> includeDependencies; // file -> includes [nearest line, include]
|
||||
std::vector<std::string> filesCompilationOrder; // order of files for unite to one file
|
||||
std::map<std::string, std::map<SgStatement*, std::vector<SgStatement*>>> exctactedModuleStats; // file -> hided excluded modules
|
||||
//
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2417"
|
||||
#define VERSION_SPF "2418"
|
||||
|
||||
@@ -1308,7 +1308,7 @@ int SPF_GetIntrinsics(void*& context, short *&result)
|
||||
return (int)resVal.size() + 1;
|
||||
}
|
||||
|
||||
extern map<string, vector<pair<int, string>>> includeDependencies;
|
||||
extern map<string, map<int, set<string>>> includeDependencies;
|
||||
int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, short *projName, short *&result, short*& output, int*& outputSize,
|
||||
short*& outputMessage, int*& outputMessageSize)
|
||||
{
|
||||
@@ -1328,13 +1328,16 @@ int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, s
|
||||
includes["file"] = deps.first;
|
||||
|
||||
json array = json::array();
|
||||
for (const auto& [line, incl] : deps.second)
|
||||
for (const auto& [line, incls] : deps.second)
|
||||
{
|
||||
for (auto& incl : incls)
|
||||
{
|
||||
json elem;
|
||||
elem["line"] = line;
|
||||
elem["dependencyFileName"] = incl;
|
||||
array.push_back(elem);
|
||||
}
|
||||
}
|
||||
includes["includes"] = array;
|
||||
inc_array.push_back(includes);
|
||||
}
|
||||
@@ -2189,7 +2192,7 @@ int SPF_InlineProcedures(void*& context, int winHandler, short* options, short*
|
||||
}
|
||||
|
||||
|
||||
extern map<string, vector<pair<int, string>>> filesToInclude;
|
||||
extern map<string, map<int, set<string>>> filesToInclude;
|
||||
int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short *projName, short *folderName, char *visFilesToInclude,
|
||||
short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize)
|
||||
{
|
||||
@@ -2222,9 +2225,8 @@ int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short
|
||||
if (sscanf(splited[k].c_str(), "%d", &line) == -1)
|
||||
return -5;
|
||||
|
||||
auto pair = make_pair(line, splited[k + 1]);
|
||||
filesToInclude[file].push_back(pair);
|
||||
__spf_print(1, " include = [%d %s]\n", pair.first, pair.second.c_str());
|
||||
filesToInclude[file][line].insert(splited[k + 1]);
|
||||
__spf_print(1, " include = [%d %s]\n", line, splited[k + 1].c_str());
|
||||
}
|
||||
i += 2 * num;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user