Several small refactorizations
This commit is contained in:
parent
40401534d7
commit
718fcfda46
|
@ -21,7 +21,6 @@
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
AnalyzerInformation::AnalyzerInformation() {}
|
|
||||||
AnalyzerInformation::~AnalyzerInformation()
|
AnalyzerInformation::~AnalyzerInformation()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
|
@ -96,16 +95,13 @@ bool AnalyzerInformation::analyzeFile(const std::string &buildDir, const std::st
|
||||||
|
|
||||||
analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(buildDir,sourcefile);
|
analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(buildDir,sourcefile);
|
||||||
|
|
||||||
const std::string start = "<analyzerinfo checksum=\"" + std::to_string(checksum) + "\">";
|
if (skipAnalysis(analyzerInfoFile, checksum, errors))
|
||||||
|
|
||||||
if (skipAnalysis(analyzerInfoFile, checksum, errors)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
fout.open(analyzerInfoFile);
|
fout.open(analyzerInfoFile);
|
||||||
if (fout.is_open()) {
|
if (fout.is_open()) {
|
||||||
fout << "<?xml version=\"1.0\"?>\n";
|
fout << "<?xml version=\"1.0\"?>\n";
|
||||||
fout << start << '\n';
|
fout << "<analyzerinfo checksum=\"" << checksum << "\">\n";
|
||||||
} else {
|
} else {
|
||||||
analyzerInfoFile.clear();
|
analyzerInfoFile.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
*/
|
*/
|
||||||
class CPPCHECKLIB AnalyzerInformation {
|
class CPPCHECKLIB AnalyzerInformation {
|
||||||
public:
|
public:
|
||||||
AnalyzerInformation();
|
|
||||||
~AnalyzerInformation();
|
~AnalyzerInformation();
|
||||||
|
|
||||||
/** Close current TU.analyzerinfo file */
|
/** Close current TU.analyzerinfo file */
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "symboldatabase.h"
|
#include "symboldatabase.h"
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
#include <set>
|
|
||||||
|
|
||||||
static bool astIsCharWithSign(const Token *tok, ValueType::Sign sign)
|
static bool astIsCharWithSign(const Token *tok, ValueType::Sign sign)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,9 +23,8 @@
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
//#include <iostream>
|
|
||||||
|
|
||||||
void ImportProject::ignorePaths(std::vector<std::string> &ipaths)
|
void ImportProject::ignorePaths(const std::vector<std::string> &ipaths)
|
||||||
{
|
{
|
||||||
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
|
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
|
||||||
bool ignore = false;
|
bool ignore = false;
|
||||||
|
@ -99,7 +98,7 @@ static bool simplifyPathWithVariables(std::string &s, const std::map<std::string
|
||||||
std::string::size_type end = s.find(')',start);
|
std::string::size_type end = s.find(')',start);
|
||||||
if (end == std::string::npos)
|
if (end == std::string::npos)
|
||||||
break;
|
break;
|
||||||
const std::string &var = s.substr(start+2,end-start-2);
|
const std::string var = s.substr(start+2,end-start-2);
|
||||||
if (expanded.find(var) != expanded.end())
|
if (expanded.find(var) != expanded.end())
|
||||||
break;
|
break;
|
||||||
expanded.insert(var);
|
expanded.insert(var);
|
||||||
|
@ -175,8 +174,8 @@ void ImportProject::importCompileCommands(std::istream &istr)
|
||||||
tokenList.createTokens(istr);
|
tokenList.createTokens(istr);
|
||||||
for (const Token *tok = tokenList.front(); tok; tok = tok->next()) {
|
for (const Token *tok = tokenList.front(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "%str% : %str% [,}]")) {
|
if (Token::Match(tok, "%str% : %str% [,}]")) {
|
||||||
const std::string key = tok->str();
|
const std::string& key = tok->str();
|
||||||
const std::string value = tok->strAt(2);
|
const std::string& value = tok->strAt(2);
|
||||||
values[key.substr(1, key.size() - 2U)] = value.substr(1, value.size() - 2U);
|
values[key.substr(1, key.size() - 2U)] = value.substr(1, value.size() - 2U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +183,7 @@ void ImportProject::importCompileCommands(std::istream &istr)
|
||||||
if (!values["file"].empty() && !values["command"].empty()) {
|
if (!values["file"].empty() && !values["command"].empty()) {
|
||||||
struct FileSettings fs;
|
struct FileSettings fs;
|
||||||
fs.filename = Path::fromNativeSeparators(values["file"]);
|
fs.filename = Path::fromNativeSeparators(values["file"]);
|
||||||
const std::string command = values["command"];
|
const std::string& command = values["command"];
|
||||||
const std::string directory = Path::fromNativeSeparators(values["directory"]);
|
const std::string directory = Path::fromNativeSeparators(values["directory"]);
|
||||||
std::string::size_type pos = 0;
|
std::string::size_type pos = 0;
|
||||||
while (std::string::npos != (pos = command.find(' ',pos))) {
|
while (std::string::npos != (pos = command.find(' ',pos))) {
|
||||||
|
@ -224,7 +223,6 @@ void ImportProject::importSln(std::istream &istr, const std::string &path)
|
||||||
{
|
{
|
||||||
std::map<std::string,std::string> variables;
|
std::map<std::string,std::string> variables;
|
||||||
variables["SolutionDir"] = path;
|
variables["SolutionDir"] = path;
|
||||||
std::string additionalIncludeDirectories;
|
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(istr,line)) {
|
while (std::getline(istr,line)) {
|
||||||
|
@ -237,7 +235,7 @@ void ImportProject::importSln(std::istream &istr, const std::string &path)
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
continue;
|
continue;
|
||||||
const std::string vcxproj(line.substr(pos1+1, pos-pos1+7));
|
const std::string vcxproj(line.substr(pos1+1, pos-pos1+7));
|
||||||
importVcxproj(path + Path::fromNativeSeparators(vcxproj), variables, additionalIncludeDirectories);
|
importVcxproj(path + Path::fromNativeSeparators(vcxproj), variables, emptyString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
#define importprojectH
|
#define importprojectH
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "platform.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "config.h"
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
/// @addtogroup Core
|
/// @addtogroup Core
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -52,7 +52,7 @@ public:
|
||||||
};
|
};
|
||||||
std::list<FileSettings> fileSettings;
|
std::list<FileSettings> fileSettings;
|
||||||
|
|
||||||
void ignorePaths(std::vector<std::string> &ipaths);
|
void ignorePaths(const std::vector<std::string> &ipaths);
|
||||||
void ignoreOtherConfigs(const std::string &cfg);
|
void ignoreOtherConfigs(const std::string &cfg);
|
||||||
void ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType);
|
void ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue