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.
This commit is contained in:
Oliver Stöneberg 2023-11-04 13:33:10 +01:00 committed by GitHub
parent ca6d1aafdb
commit df860a937d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -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 (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) {
if (project.guiProject.analyzeAllVsConfigs == "false") if (project.guiProject.analyzeAllVsConfigs == "false")
project.selectOneVsConfig(mSettings.platform.type); project.selectOneVsConfig(mSettings.platform.type);
if (!CppCheckExecutor::tryLoadLibrary(mSettings.library, argv[0], "windows.cfg")) { mSettings.libraries.emplace_back("windows");
// This shouldn't happen normally.
mLogger.printError("failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install.");
return false;
}
} }
if (projType == ImportProject::Type::MISSING) { if (projType == ImportProject::Type::MISSING) {
mLogger.printError("failed to open project '" + projectFile + "'. The file does not exist."); mLogger.printError("failed to open project '" + projectFile + "'. The file does not exist.");

View File

@ -73,6 +73,8 @@ public:
*/ */
int check(int argc, const char* const argv[]); int check(int argc, const char* const argv[]);
private:
/** /**
* Information about progress is directed here. This should be * Information about progress is directed here. This should be
* called by the CppCheck class only. * 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; void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override;
public:
/** /**
* @param exceptionOutput Output file * @param exceptionOutput Output file
*/ */
@ -95,6 +99,8 @@ public:
*/ */
static FILE* getExceptionOutput(); static FILE* getExceptionOutput();
private:
/** /**
* Tries to load a library and prints warning/error messages * Tries to load a library and prints warning/error messages
* @return false, if an error occurred (except unknown XML elements) * @return false, if an error occurred (except unknown XML elements)
@ -106,8 +112,6 @@ public:
*/ */
static int executeCommand(std::string exe, std::vector<std::string> args, std::string redirect, std::string &output_); static int executeCommand(std::string exe, std::vector<std::string> args, std::string redirect, std::string &output_);
protected:
/** /**
* Helper function to print out errors. Appends a line change. * Helper function to print out errors. Appends a line change.
* @param errmsg String printed to error stream * @param errmsg String printed to error stream
@ -125,8 +129,6 @@ protected:
*/ */
bool parseFromArgs(Settings &settings, int argc, const char* const argv[]); bool parseFromArgs(Settings &settings, int argc, const char* const argv[]);
private:
static bool reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map<std::string, std::size_t> &files, ErrorLogger& errorLogger); static bool reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map<std::string, std::size_t> &files, ErrorLogger& errorLogger);
/** /**