Skip to content

Commit df860a9

Browse files
authored
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.
1 parent ca6d1aa commit df860a9

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
713713
if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) {
714714
if (project.guiProject.analyzeAllVsConfigs == "false")
715715
project.selectOneVsConfig(mSettings.platform.type);
716-
if (!CppCheckExecutor::tryLoadLibrary(mSettings.library, argv[0], "windows.cfg")) {
717-
// This shouldn't happen normally.
718-
mLogger.printError("failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install.");
719-
return false;
720-
}
716+
mSettings.libraries.emplace_back("windows");
721717
}
722718
if (projType == ImportProject::Type::MISSING) {
723719
mLogger.printError("failed to open project '" + projectFile + "'. The file does not exist.");

cli/cppcheckexecutor.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class CppCheckExecutor : public ErrorLogger {
7373
*/
7474
int check(int argc, const char* const argv[]);
7575

76+
private:
77+
7678
/**
7779
* Information about progress is directed here. This should be
7880
* called by the CppCheck class only.
@@ -86,6 +88,8 @@ class CppCheckExecutor : public ErrorLogger {
8688

8789
void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override;
8890

91+
public:
92+
8993
/**
9094
* @param exceptionOutput Output file
9195
*/
@@ -95,6 +99,8 @@ class CppCheckExecutor : public ErrorLogger {
9599
*/
96100
static FILE* getExceptionOutput();
97101

102+
private:
103+
98104
/**
99105
* Tries to load a library and prints warning/error messages
100106
* @return false, if an error occurred (except unknown XML elements)
@@ -106,8 +112,6 @@ class CppCheckExecutor : public ErrorLogger {
106112
*/
107113
static int executeCommand(std::string exe, std::vector<std::string> args, std::string redirect, std::string &output_);
108114

109-
protected:
110-
111115
/**
112116
* Helper function to print out errors. Appends a line change.
113117
* @param errmsg String printed to error stream
@@ -125,8 +129,6 @@ class CppCheckExecutor : public ErrorLogger {
125129
*/
126130
bool parseFromArgs(Settings &settings, int argc, const char* const argv[]);
127131

128-
private:
129-
130132
static bool reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map<std::string, std::size_t> &files, ErrorLogger& errorLogger);
131133

132134
/**

0 commit comments

Comments
 (0)