From df860a937d0a5505a808aaeaadcbecd9dcd96148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 4 Nov 2023 13:33:10 +0100 Subject: [PATCH] do not explicitly load `windows.cfg` during command-line parsing (#5613) As we now fail early on loading of all libraries we no longer need to explicitly bail out on mandatory ones. This would have also caused `libraries` and `library` to go out-of-sync and possibly lead to duplicated loading of the library. It also allows for a `CppCheckExecutor` to be made private. --- cli/cmdlineparser.cpp | 6 +----- cli/cppcheckexecutor.h | 10 ++++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 0f478f87a..14ef48ccb 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -713,11 +713,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) { if (project.guiProject.analyzeAllVsConfigs == "false") project.selectOneVsConfig(mSettings.platform.type); - if (!CppCheckExecutor::tryLoadLibrary(mSettings.library, argv[0], "windows.cfg")) { - // This shouldn't happen normally. - mLogger.printError("failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install."); - return false; - } + mSettings.libraries.emplace_back("windows"); } if (projType == ImportProject::Type::MISSING) { mLogger.printError("failed to open project '" + projectFile + "'. The file does not exist."); diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 1e4ec1db9..ca66558a0 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -73,6 +73,8 @@ public: */ int check(int argc, const char* const argv[]); +private: + /** * Information about progress is directed here. This should be * called by the CppCheck class only. @@ -86,6 +88,8 @@ public: void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override; +public: + /** * @param exceptionOutput Output file */ @@ -95,6 +99,8 @@ public: */ static FILE* getExceptionOutput(); +private: + /** * Tries to load a library and prints warning/error messages * @return false, if an error occurred (except unknown XML elements) @@ -106,8 +112,6 @@ public: */ static int executeCommand(std::string exe, std::vector args, std::string redirect, std::string &output_); -protected: - /** * Helper function to print out errors. Appends a line change. * @param errmsg String printed to error stream @@ -125,8 +129,6 @@ protected: */ bool parseFromArgs(Settings &settings, int argc, const char* const argv[]); -private: - static bool reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map &files, ErrorLogger& errorLogger); /**