From 718fcfda467efd904add8c69f0745f840a3711eb Mon Sep 17 00:00:00 2001 From: PKEuS Date: Tue, 6 Dec 2016 20:02:43 +0100 Subject: [PATCH] Several small refactorizations --- lib/analyzerinfo.cpp | 8 ++------ lib/analyzerinfo.h | 1 - lib/astutils.cpp | 1 - lib/importproject.cpp | 14 ++++++-------- lib/importproject.h | 6 +++--- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/lib/analyzerinfo.cpp b/lib/analyzerinfo.cpp index e1d4539d1..8c7027244 100644 --- a/lib/analyzerinfo.cpp +++ b/lib/analyzerinfo.cpp @@ -21,7 +21,6 @@ #include #include -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 = ""; - - if (skipAnalysis(analyzerInfoFile, checksum, errors)) { + if (skipAnalysis(analyzerInfoFile, checksum, errors)) return false; - } fout.open(analyzerInfoFile); if (fout.is_open()) { fout << "\n"; - fout << start << '\n'; + fout << "\n"; } else { analyzerInfoFile.clear(); } diff --git a/lib/analyzerinfo.h b/lib/analyzerinfo.h index 7e68c16fd..d50054c4d 100644 --- a/lib/analyzerinfo.h +++ b/lib/analyzerinfo.h @@ -45,7 +45,6 @@ */ class CPPCHECKLIB AnalyzerInformation { public: - AnalyzerInformation(); ~AnalyzerInformation(); /** Close current TU.analyzerinfo file */ diff --git a/lib/astutils.cpp b/lib/astutils.cpp index c5ea05689..9b91cd97c 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -23,7 +23,6 @@ #include "symboldatabase.h" #include "token.h" #include "tokenize.h" -#include static bool astIsCharWithSign(const Token *tok, ValueType::Sign sign) { diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 166f0b7ff..58442dfd7 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -23,9 +23,8 @@ #include "token.h" #include "tinyxml2.h" #include -//#include -void ImportProject::ignorePaths(std::vector &ipaths) +void ImportProject::ignorePaths(const std::vector &ipaths) { for (std::list::iterator it = fileSettings.begin(); it != fileSettings.end();) { bool ignore = false; @@ -99,7 +98,7 @@ static bool simplifyPathWithVariables(std::string &s, const std::mapnext()) { 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 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); } } diff --git a/lib/importproject.h b/lib/importproject.h index 93fe60d88..5d8c2d058 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -21,13 +21,13 @@ #define importprojectH //--------------------------------------------------------------------------- +#include "config.h" +#include "platform.h" #include #include #include #include #include -#include "config.h" -#include "platform.h" /// @addtogroup Core /// @{ @@ -52,7 +52,7 @@ public: }; std::list fileSettings; - void ignorePaths(std::vector &ipaths); + void ignorePaths(const std::vector &ipaths); void ignoreOtherConfigs(const std::string &cfg); void ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType);