Several small refactorizations

This commit is contained in:
PKEuS 2016-12-06 20:02:43 +01:00
parent 40401534d7
commit 718fcfda46
5 changed files with 11 additions and 19 deletions

View File

@ -21,7 +21,6 @@
#include <tinyxml2.h>
#include <sstream>
AnalyzerInformation::AnalyzerInformation() {}
AnalyzerInformation::~AnalyzerInformation()
{
close();
@ -96,16 +95,13 @@ bool AnalyzerInformation::analyzeFile(const std::string &buildDir, const std::st
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;
}
fout.open(analyzerInfoFile);
if (fout.is_open()) {
fout << "<?xml version=\"1.0\"?>\n";
fout << start << '\n';
fout << "<analyzerinfo checksum=\"" << checksum << "\">\n";
} else {
analyzerInfoFile.clear();
}

View File

@ -45,7 +45,6 @@
*/
class CPPCHECKLIB AnalyzerInformation {
public:
AnalyzerInformation();
~AnalyzerInformation();
/** Close current TU.analyzerinfo file */

View File

@ -23,7 +23,6 @@
#include "symboldatabase.h"
#include "token.h"
#include "tokenize.h"
#include <set>
static bool astIsCharWithSign(const Token *tok, ValueType::Sign sign)
{

View File

@ -23,9 +23,8 @@
#include "token.h"
#include "tinyxml2.h"
#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();) {
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);
if (end == std::string::npos)
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())
break;
expanded.insert(var);
@ -175,8 +174,8 @@ void ImportProject::importCompileCommands(std::istream &istr)
tokenList.createTokens(istr);
for (const Token *tok = tokenList.front(); tok; tok = tok->next()) {
if (Token::Match(tok, "%str% : %str% [,}]")) {
const std::string key = tok->str();
const std::string value = tok->strAt(2);
const std::string& key = tok->str();
const std::string& value = tok->strAt(2);
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()) {
struct FileSettings fs;
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"]);
std::string::size_type pos = 0;
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;
variables["SolutionDir"] = path;
std::string additionalIncludeDirectories;
std::string 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)
continue;
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);
}
}

View File

@ -21,13 +21,13 @@
#define importprojectH
//---------------------------------------------------------------------------
#include "config.h"
#include "platform.h"
#include <list>
#include <map>
#include <string>
#include <set>
#include <vector>
#include "config.h"
#include "platform.h"
/// @addtogroup Core
/// @{
@ -52,7 +52,7 @@ public:
};
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 ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType);