fixed BUILD_INCLUDE_DEPENDENCIES pass
This commit is contained in:
@@ -331,9 +331,10 @@ 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,
|
unparseToBuf = removeIncludeStatsAndUnparse(file, file_name, fout_name.c_str(), allIncludeFiles, out_free_form == 1, moduleUsesByFile,
|
||||||
moduleDecls, getObjectForFileFromMap(file_name, exctactedModuleStats), toString, false, true);
|
moduleDecls, getObjectForFileFromMap(file_name, exctactedModuleStats), toString, false, true);
|
||||||
auto itI = filesToInclude.find(file_name);
|
auto itI = filesToInclude.find(file_name);
|
||||||
for (auto& [_, incl] : itI->second)
|
for (auto& [_, incls] : itI->second)
|
||||||
if (allIncludeFiles.find(incl) != allIncludeFiles.end())
|
for (auto& incl : incls)
|
||||||
allIncludeFiles.erase(incl);
|
if (allIncludeFiles.find(incl) != allIncludeFiles.end())
|
||||||
|
allIncludeFiles.erase(incl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -827,7 +828,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
{
|
{
|
||||||
auto fileIt = includeDependencies.find(file_name);
|
auto fileIt = includeDependencies.find(file_name);
|
||||||
if (fileIt == includeDependencies.end())
|
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;
|
set<string> modFiles;
|
||||||
for (auto& elem : moduleDecls)
|
for (auto& elem : moduleDecls)
|
||||||
@@ -844,7 +845,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
{
|
{
|
||||||
if (lastFromFile == NULL)
|
if (lastFromFile == NULL)
|
||||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
fileIt->second.push_back(make_pair(lastFromFile->lineNumber(), st->fileName()));
|
fileIt->second[lastFromFile->lineNumber()].insert(st->fileName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lastFromFile = st;
|
lastFromFile = st;
|
||||||
@@ -1603,12 +1604,15 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
|
|||||||
set<string> includedToThisFile;
|
set<string> includedToThisFile;
|
||||||
if (itDep != includeDependencies.end())
|
if (itDep != includeDependencies.end())
|
||||||
{
|
{
|
||||||
for (auto& [_, incl] : itDep->second)
|
for (auto& [_, incls] : itDep->second)
|
||||||
{
|
{
|
||||||
auto comm = commentsToInclude.find(incl);
|
for (auto& incl : incls)
|
||||||
if (comm != commentsToInclude.end())
|
{
|
||||||
for (auto &allComm : comm->second)
|
auto comm = commentsToInclude.find(incl);
|
||||||
includedToThisFile.insert(allComm.second.begin(), allComm.second.end());
|
if (comm != commentsToInclude.end())
|
||||||
|
for (auto& allComm : comm->second)
|
||||||
|
includedToThisFile.insert(allComm.second.begin(), allComm.second.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ std::map<std::string, std::map<int, std::set<std::string>>> commentsToInclude;
|
|||||||
//
|
//
|
||||||
|
|
||||||
//for INSERT_INCLUDES
|
//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
|
//for PASSES DEPENDENSIES
|
||||||
@@ -96,7 +96,7 @@ std::set<passes> passesIgnoreStateDone;
|
|||||||
//for files info
|
//for files info
|
||||||
std::map<std::string, int> lineInfo; // file -> lines count
|
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::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::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
|
std::map<std::string, std::map<SgStatement*, std::vector<SgStatement*>>> exctactedModuleStats; // file -> hided excluded modules
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#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;
|
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,
|
int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, short *projName, short *&result, short*& output, int*& outputSize,
|
||||||
short*& outputMessage, int*& outputMessageSize)
|
short*& outputMessage, int*& outputMessageSize)
|
||||||
{
|
{
|
||||||
@@ -1328,12 +1328,15 @@ int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, s
|
|||||||
includes["file"] = deps.first;
|
includes["file"] = deps.first;
|
||||||
|
|
||||||
json array = json::array();
|
json array = json::array();
|
||||||
for (const auto& [line, incl] : deps.second)
|
for (const auto& [line, incls] : deps.second)
|
||||||
{
|
{
|
||||||
json elem;
|
for (auto& incl : incls)
|
||||||
elem["line"] = line;
|
{
|
||||||
elem["dependencyFileName"] = incl;
|
json elem;
|
||||||
array.push_back(elem);
|
elem["line"] = line;
|
||||||
|
elem["dependencyFileName"] = incl;
|
||||||
|
array.push_back(elem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
includes["includes"] = array;
|
includes["includes"] = array;
|
||||||
inc_array.push_back(includes);
|
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,
|
int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short *projName, short *folderName, char *visFilesToInclude,
|
||||||
short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize)
|
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)
|
if (sscanf(splited[k].c_str(), "%d", &line) == -1)
|
||||||
return -5;
|
return -5;
|
||||||
|
|
||||||
auto pair = make_pair(line, splited[k + 1]);
|
filesToInclude[file][line].insert(splited[k + 1]);
|
||||||
filesToInclude[file].push_back(pair);
|
__spf_print(1, " include = [%d %s]\n", line, splited[k + 1].c_str());
|
||||||
__spf_print(1, " include = [%d %s]\n", pair.first, pair.second.c_str());
|
|
||||||
}
|
}
|
||||||
i += 2 * num;
|
i += 2 * num;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user