Skip to content

Commit 9028b4a

Browse files
firewavedanmar
authored andcommitted
do not access static methods through instance (cppcheck-opensource#2189)
1 parent 49b7ef8 commit 9028b4a

9 files changed

Lines changed: 56 additions & 57 deletions

cli/cppcheckexecutor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
9696

9797
if (success) {
9898
if (parser.getShowVersion() && !parser.getShowErrorMessages()) {
99-
const char * const extraVersion = cppcheck->extraVersion();
99+
const char * const extraVersion = CppCheck::extraVersion();
100100
if (*extraVersion != 0)
101-
std::cout << "Cppcheck " << cppcheck->version() << " ("
101+
std::cout << "Cppcheck " << CppCheck::version() << " ("
102102
<< extraVersion << ')' << std::endl;
103103
else
104-
std::cout << "Cppcheck " << cppcheck->version() << std::endl;
104+
std::cout << "Cppcheck " << CppCheck::version() << std::endl;
105105
}
106106

107107
if (parser.getShowErrorMessages()) {
@@ -112,7 +112,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
112112
}
113113

114114
if (parser.exitAfterPrinting()) {
115-
settings.terminate();
115+
Settings::terminate();
116116
return true;
117117
}
118118
} else {
@@ -189,7 +189,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
189189
if (!parseFromArgs(&cppCheck, argc, argv)) {
190190
return EXIT_FAILURE;
191191
}
192-
if (settings.terminated()) {
192+
if (Settings::terminated()) {
193193
return EXIT_SUCCESS;
194194
}
195195
if (cppCheck.settings().exceptionHandling) {

lib/checkleakautovar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void VarInfo::possibleUsageAll(const std::string &functionName)
127127
void CheckLeakAutoVar::leakError(const Token *tok, const std::string &varname, int type)
128128
{
129129
const CheckMemoryLeak checkmemleak(mTokenizer, mErrorLogger, mSettings);
130-
if (mSettings->library.isresource(type))
130+
if (Library::isresource(type))
131131
checkmemleak.resourceLeakError(tok, varname);
132132
else
133133
checkmemleak.memleakError(tok, varname);
@@ -163,7 +163,7 @@ void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &fu
163163

164164
void CheckLeakAutoVar::doubleFreeError(const Token *tok, const std::string &varname, int type)
165165
{
166-
if (mSettings->library.isresource(type))
166+
if (Library::isresource(type))
167167
reportError(tok, Severity::error, "doubleFree", "$symbol:" + varname + "\nResource handle '$symbol' freed twice.", CWE415, false);
168168
else
169169
reportError(tok, Severity::error, "doubleFree", "$symbol:" + varname + "\nMemory pointed to by '$symbol' is freed twice.", CWE415, false);

lib/checkunusedfunctions.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ class CPPCHECKLIB CheckUnusedFunctions : public Check {
7979
private:
8080

8181
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
82-
CheckUnusedFunctions c(nullptr, settings, errorLogger);
83-
c.unusedFunctionError(errorLogger, emptyString, 0, "funcName");
82+
CheckUnusedFunctions::unusedFunctionError(errorLogger, emptyString, 0, "funcName");
8483
}
8584

8685
void runChecks(const Tokenizer * /*tokenizer*/, const Settings * /*settings*/, ErrorLogger * /*errorLogger*/) OVERRIDE {}

lib/cppcheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
223223
if (!Path::acceptFile(filename))
224224
mSettings.debugwarnings = false;
225225

226-
if (mSettings.terminated())
226+
if (Settings::terminated())
227227
return mExitCode;
228228

229229
if (!mSettings.quiet) {
@@ -432,7 +432,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
432432
std::list<std::string> configurationError;
433433
for (const std::string &currCfg : configurations) {
434434
// bail out if terminated
435-
if (mSettings.terminated())
435+
if (Settings::terminated())
436436
break;
437437

438438
// Check only a few configurations (default 12), after that bail out, unless --force
@@ -549,7 +549,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
549549
if (!result)
550550
continue;
551551

552-
if (!mSettings.terminated())
552+
if (!Settings::terminated())
553553
executeRules("simple", mTokenizer);
554554
}
555555

@@ -717,10 +717,10 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
717717
{
718718
// call all "runChecks" in all registered Check classes
719719
for (Check *check : Check::instances()) {
720-
if (mSettings.terminated())
720+
if (Settings::terminated())
721721
return;
722722

723-
if (tokenizer.isMaxTime())
723+
if (Tokenizer::isMaxTime())
724724
return;
725725

726726
Timer timerRunChecks(check->name() + "::runChecks", mSettings.showtime, &S_timerResults);

lib/cppcheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class CPPCHECKLIB CppCheck : ErrorLogger {
113113
* @brief Terminate checking. The checking will be terminated as soon as possible.
114114
*/
115115
void terminate() {
116-
mSettings.terminate();
116+
Settings::terminate();
117117
}
118118

119119
/**

lib/token.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ class CPPCHECKLIB Token {
955955
}
956956

957957
const std::list<ValueFlow::Value>& values() const {
958-
return mImpl->mValues ? *mImpl->mValues : mImpl->mEmptyValueList;
958+
return mImpl->mValues ? *mImpl->mValues : TokenImpl::mEmptyValueList;
959959
}
960960

961961
/**

0 commit comments

Comments
 (0)