--cppcheck-build-dir: generate unique analyzeinfo filenames when source files have same names
This commit is contained in:
parent
3b57273ef1
commit
7d7212c465
|
@ -120,8 +120,11 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
return true;
|
||||
}
|
||||
|
||||
else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0)
|
||||
_settings->buildDir = argv[i] + 21;
|
||||
else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0) {
|
||||
_settings->buildDir = Path::fromNativeSeparators(argv[i] + 21);
|
||||
if (_settings->buildDir.back() == '/')
|
||||
_settings->buildDir.erase(_settings->buildDir.size() - 1U);
|
||||
}
|
||||
|
||||
// Flag used for various purposes during debugging
|
||||
else if (std::strcmp(argv[i], "--debug") == 0)
|
||||
|
|
|
@ -802,6 +802,14 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
|
|||
reportErr(ErrorLogger::ErrorMessage::getXMLHeader(settings.xml_version));
|
||||
}
|
||||
|
||||
if (!settings.buildDir.empty()) {
|
||||
const std::string filename(settings.buildDir + "/files.txt");
|
||||
std::ofstream fout(filename.c_str());
|
||||
for (std::map<std::string, std::size_t>::const_iterator f = _files.begin(); f != _files.end(); ++f) {
|
||||
fout << f->first << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int returnValue = 0;
|
||||
if (settings.jobs == 1) {
|
||||
// Single process
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "analyzerinfo.h"
|
||||
#include "path.h"
|
||||
#include <tinyxml2.h>
|
||||
#include <sstream>
|
||||
|
||||
AnalyzerInformation::AnalyzerInformation() {}
|
||||
AnalyzerInformation::~AnalyzerInformation()
|
||||
|
@ -60,6 +61,21 @@ static bool skipAnalysis(const std::string &analyzerInfoFile, unsigned long long
|
|||
|
||||
std::string AnalyzerInformation::getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile)
|
||||
{
|
||||
const std::string files(buildDir + "/files.txt");
|
||||
std::ifstream fin(files.c_str());
|
||||
if (fin.is_open()) {
|
||||
int id = 1;
|
||||
std::string line;
|
||||
while (std::getline(fin,line)) {
|
||||
if (line == sourcefile) {
|
||||
std::ostringstream ostr;
|
||||
ostr << buildDir << '/' << id << ".analyzeinfo";
|
||||
return ostr.str();
|
||||
}
|
||||
id++;
|
||||
}
|
||||
}
|
||||
|
||||
std::string filename = Path::fromNativeSeparators(buildDir);
|
||||
if (filename.back() != '/')
|
||||
filename += '/';
|
||||
|
|
Loading…
Reference in New Issue