do not access static methods through instance (#2189)
This commit is contained in:
parent
49b7ef84d9
commit
9028b4a81d
|
@ -96,12 +96,12 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
if (parser.getShowVersion() && !parser.getShowErrorMessages()) {
|
if (parser.getShowVersion() && !parser.getShowErrorMessages()) {
|
||||||
const char * const extraVersion = cppcheck->extraVersion();
|
const char * const extraVersion = CppCheck::extraVersion();
|
||||||
if (*extraVersion != 0)
|
if (*extraVersion != 0)
|
||||||
std::cout << "Cppcheck " << cppcheck->version() << " ("
|
std::cout << "Cppcheck " << CppCheck::version() << " ("
|
||||||
<< extraVersion << ')' << std::endl;
|
<< extraVersion << ')' << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << "Cppcheck " << cppcheck->version() << std::endl;
|
std::cout << "Cppcheck " << CppCheck::version() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.getShowErrorMessages()) {
|
if (parser.getShowErrorMessages()) {
|
||||||
|
@ -112,7 +112,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.exitAfterPrinting()) {
|
if (parser.exitAfterPrinting()) {
|
||||||
settings.terminate();
|
Settings::terminate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,7 +189,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
|
||||||
if (!parseFromArgs(&cppCheck, argc, argv)) {
|
if (!parseFromArgs(&cppCheck, argc, argv)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (settings.terminated()) {
|
if (Settings::terminated()) {
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
if (cppCheck.settings().exceptionHandling) {
|
if (cppCheck.settings().exceptionHandling) {
|
||||||
|
|
|
@ -127,7 +127,7 @@ void VarInfo::possibleUsageAll(const std::string &functionName)
|
||||||
void CheckLeakAutoVar::leakError(const Token *tok, const std::string &varname, int type)
|
void CheckLeakAutoVar::leakError(const Token *tok, const std::string &varname, int type)
|
||||||
{
|
{
|
||||||
const CheckMemoryLeak checkmemleak(mTokenizer, mErrorLogger, mSettings);
|
const CheckMemoryLeak checkmemleak(mTokenizer, mErrorLogger, mSettings);
|
||||||
if (mSettings->library.isresource(type))
|
if (Library::isresource(type))
|
||||||
checkmemleak.resourceLeakError(tok, varname);
|
checkmemleak.resourceLeakError(tok, varname);
|
||||||
else
|
else
|
||||||
checkmemleak.memleakError(tok, varname);
|
checkmemleak.memleakError(tok, varname);
|
||||||
|
@ -163,7 +163,7 @@ void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &fu
|
||||||
|
|
||||||
void CheckLeakAutoVar::doubleFreeError(const Token *tok, const std::string &varname, int type)
|
void CheckLeakAutoVar::doubleFreeError(const Token *tok, const std::string &varname, int type)
|
||||||
{
|
{
|
||||||
if (mSettings->library.isresource(type))
|
if (Library::isresource(type))
|
||||||
reportError(tok, Severity::error, "doubleFree", "$symbol:" + varname + "\nResource handle '$symbol' freed twice.", CWE415, false);
|
reportError(tok, Severity::error, "doubleFree", "$symbol:" + varname + "\nResource handle '$symbol' freed twice.", CWE415, false);
|
||||||
else
|
else
|
||||||
reportError(tok, Severity::error, "doubleFree", "$symbol:" + varname + "\nMemory pointed to by '$symbol' is freed twice.", CWE415, false);
|
reportError(tok, Severity::error, "doubleFree", "$symbol:" + varname + "\nMemory pointed to by '$symbol' is freed twice.", CWE415, false);
|
||||||
|
|
|
@ -79,8 +79,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
|
||||||
CheckUnusedFunctions c(nullptr, settings, errorLogger);
|
CheckUnusedFunctions::unusedFunctionError(errorLogger, emptyString, 0, "funcName");
|
||||||
c.unusedFunctionError(errorLogger, emptyString, 0, "funcName");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void runChecks(const Tokenizer * /*tokenizer*/, const Settings * /*settings*/, ErrorLogger * /*errorLogger*/) OVERRIDE {}
|
void runChecks(const Tokenizer * /*tokenizer*/, const Settings * /*settings*/, ErrorLogger * /*errorLogger*/) OVERRIDE {}
|
||||||
|
|
|
@ -223,7 +223,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
if (!Path::acceptFile(filename))
|
if (!Path::acceptFile(filename))
|
||||||
mSettings.debugwarnings = false;
|
mSettings.debugwarnings = false;
|
||||||
|
|
||||||
if (mSettings.terminated())
|
if (Settings::terminated())
|
||||||
return mExitCode;
|
return mExitCode;
|
||||||
|
|
||||||
if (!mSettings.quiet) {
|
if (!mSettings.quiet) {
|
||||||
|
@ -432,7 +432,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
std::list<std::string> configurationError;
|
std::list<std::string> configurationError;
|
||||||
for (const std::string &currCfg : configurations) {
|
for (const std::string &currCfg : configurations) {
|
||||||
// bail out if terminated
|
// bail out if terminated
|
||||||
if (mSettings.terminated())
|
if (Settings::terminated())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Check only a few configurations (default 12), after that bail out, unless --force
|
// 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
|
||||||
if (!result)
|
if (!result)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!mSettings.terminated())
|
if (!Settings::terminated())
|
||||||
executeRules("simple", mTokenizer);
|
executeRules("simple", mTokenizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,10 +717,10 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
|
||||||
{
|
{
|
||||||
// call all "runChecks" in all registered Check classes
|
// call all "runChecks" in all registered Check classes
|
||||||
for (Check *check : Check::instances()) {
|
for (Check *check : Check::instances()) {
|
||||||
if (mSettings.terminated())
|
if (Settings::terminated())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tokenizer.isMaxTime())
|
if (Tokenizer::isMaxTime())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Timer timerRunChecks(check->name() + "::runChecks", mSettings.showtime, &S_timerResults);
|
Timer timerRunChecks(check->name() + "::runChecks", mSettings.showtime, &S_timerResults);
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
* @brief Terminate checking. The checking will be terminated as soon as possible.
|
* @brief Terminate checking. The checking will be terminated as soon as possible.
|
||||||
*/
|
*/
|
||||||
void terminate() {
|
void terminate() {
|
||||||
mSettings.terminate();
|
Settings::terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -955,7 +955,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::list<ValueFlow::Value>& values() const {
|
const std::list<ValueFlow::Value>& values() const {
|
||||||
return mImpl->mValues ? *mImpl->mValues : mImpl->mEmptyValueList;
|
return mImpl->mValues ? *mImpl->mValues : TokenImpl::mEmptyValueList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -554,7 +554,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
if (mErrorLogger && !list.getFiles().empty())
|
if (mErrorLogger && !list.getFiles().empty())
|
||||||
mErrorLogger->reportProgress(list.getFiles()[0], "Tokenize (typedef)", tok->progressValue());
|
mErrorLogger->reportProgress(list.getFiles()[0], "Tokenize (typedef)", tok->progressValue());
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isMaxTime())
|
if (isMaxTime())
|
||||||
|
@ -1026,7 +1026,7 @@ void Tokenizer::simplifyTypedef()
|
||||||
int classLevel = spaceInfo.size();
|
int classLevel = spaceInfo.size();
|
||||||
|
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next()) {
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next()) {
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tok2->link()) { // Pre-check for performance
|
if (tok2->link()) { // Pre-check for performance
|
||||||
|
@ -1892,7 +1892,7 @@ bool Tokenizer::simplifyUsing()
|
||||||
if (mErrorLogger && !list.getFiles().empty())
|
if (mErrorLogger && !list.getFiles().empty())
|
||||||
mErrorLogger->reportProgress(list.getFiles()[0], "Tokenize (using)", tok->progressValue());
|
mErrorLogger->reportProgress(list.getFiles()[0], "Tokenize (using)", tok->progressValue());
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return substitute;
|
return substitute;
|
||||||
|
|
||||||
if (Token::Match(tok, "{|}|namespace|class|struct|union") ||
|
if (Token::Match(tok, "{|}|namespace|class|struct|union") ||
|
||||||
|
@ -1937,7 +1937,7 @@ bool Tokenizer::simplifyUsing()
|
||||||
if (start->strAt(1) != "{") {
|
if (start->strAt(1) != "{") {
|
||||||
Token *structEnd = start->linkAt(2);
|
Token *structEnd = start->linkAt(2);
|
||||||
structEnd->insertToken(";", "");
|
structEnd->insertToken(";", "");
|
||||||
list.copyTokens(structEnd->next(), tok, start->next());
|
TokenList::copyTokens(structEnd->next(), tok, start->next());
|
||||||
usingStart = structEnd->tokAt(2);
|
usingStart = structEnd->tokAt(2);
|
||||||
nameToken = usingStart->next();
|
nameToken = usingStart->next();
|
||||||
if (usingStart->strAt(2) == "=")
|
if (usingStart->strAt(2) == "=")
|
||||||
|
@ -1957,7 +1957,7 @@ bool Tokenizer::simplifyUsing()
|
||||||
newName = name;
|
newName = name;
|
||||||
else
|
else
|
||||||
newName = "Unnamed" + MathLib::toString(mUnnamedCount++);
|
newName = "Unnamed" + MathLib::toString(mUnnamedCount++);
|
||||||
list.copyTokens(structEnd->next(), tok, start);
|
TokenList::copyTokens(structEnd->next(), tok, start);
|
||||||
structEnd->tokAt(5)->insertToken(newName, "");
|
structEnd->tokAt(5)->insertToken(newName, "");
|
||||||
start->insertToken(newName, "");
|
start->insertToken(newName, "");
|
||||||
|
|
||||||
|
@ -2137,14 +2137,14 @@ bool Tokenizer::simplifyUsing()
|
||||||
// check for array syntax and add type around variable
|
// check for array syntax and add type around variable
|
||||||
if (arrayStart) {
|
if (arrayStart) {
|
||||||
if (Token::Match(tok1->next(), "%name%")) {
|
if (Token::Match(tok1->next(), "%name%")) {
|
||||||
list.copyTokens(tok1->next(), arrayStart, usingEnd->previous());
|
TokenList::copyTokens(tok1->next(), arrayStart, usingEnd->previous());
|
||||||
list.copyTokens(tok1, start, arrayStart->previous());
|
TokenList::copyTokens(tok1, start, arrayStart->previous());
|
||||||
tok1->deleteThis();
|
tok1->deleteThis();
|
||||||
substitute = true;
|
substitute = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// just replace simple type aliases
|
// just replace simple type aliases
|
||||||
list.copyTokens(tok1, start, usingEnd->previous());
|
TokenList::copyTokens(tok1, start, usingEnd->previous());
|
||||||
tok1->deleteThis();
|
tok1->deleteThis();
|
||||||
substitute = true;
|
substitute = true;
|
||||||
}
|
}
|
||||||
|
@ -3361,7 +3361,7 @@ void Tokenizer::setVarIdPass1()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// locate the variable name..
|
// locate the variable name..
|
||||||
|
@ -4222,7 +4222,7 @@ bool Tokenizer::simplifySizeof()
|
||||||
|
|
||||||
bool Tokenizer::simplifyTokenList1(const char FileName[])
|
bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
{
|
{
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// if MACRO
|
// if MACRO
|
||||||
|
@ -4282,7 +4282,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// convert C++17 style nested namespaces to old style namespaces
|
// convert C++17 style nested namespaces to old style namespaces
|
||||||
|
@ -4341,7 +4341,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Remove __declspec()
|
// Remove __declspec()
|
||||||
|
@ -4363,7 +4363,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
const Token * const end = tok;
|
const Token * const end = tok;
|
||||||
for (tok = lt; tok != end; tok = tok->next()) {
|
for (tok = lt; tok != end; tok = tok->next()) {
|
||||||
if (tok->isNumber())
|
if (tok->isNumber())
|
||||||
mTemplateSimplifier->simplifyNumericCalculations(tok);
|
TemplateSimplifier::simplifyNumericCalculations(tok);
|
||||||
}
|
}
|
||||||
lt = tok->next();
|
lt = tok->next();
|
||||||
}
|
}
|
||||||
|
@ -4387,7 +4387,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
findComplicatedSyntaxErrorsInTemplates();
|
findComplicatedSyntaxErrorsInTemplates();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// remove calling conventions __cdecl, __stdcall..
|
// remove calling conventions __cdecl, __stdcall..
|
||||||
|
@ -4414,7 +4414,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// convert Microsoft string functions
|
// convert Microsoft string functions
|
||||||
simplifyMicrosoftStringFunctions();
|
simplifyMicrosoftStringFunctions();
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Remove Qt signals and slots
|
// Remove Qt signals and slots
|
||||||
|
@ -4476,7 +4476,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
validate();
|
validate();
|
||||||
|
|
||||||
// The simplify enum have inner loops
|
// The simplify enum have inner loops
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Put ^{} statements in asm()
|
// Put ^{} statements in asm()
|
||||||
|
@ -4509,25 +4509,25 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// unsigned long long int => long (with _isUnsigned=true,_isLong=true)
|
// unsigned long long int => long (with _isUnsigned=true,_isLong=true)
|
||||||
list.simplifyStdType();
|
list.simplifyStdType();
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// simplify bit fields..
|
// simplify bit fields..
|
||||||
simplifyBitfields();
|
simplifyBitfields();
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// struct simplification "struct S {} s; => struct S { } ; S s ;
|
// struct simplification "struct S {} s; => struct S { } ; S s ;
|
||||||
simplifyStructDecl();
|
simplifyStructDecl();
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// x = ({ 123; }); => { x = 123; }
|
// x = ({ 123; }); => { x = 123; }
|
||||||
simplifyAssignmentBlock();
|
simplifyAssignmentBlock();
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
simplifyVariableMultipleAssign();
|
simplifyVariableMultipleAssign();
|
||||||
|
@ -4552,7 +4552,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// The simplifyTemplates have inner loops
|
// The simplifyTemplates have inner loops
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// sometimes the "simplifyTemplates" fail and then unsimplified
|
// sometimes the "simplifyTemplates" fail and then unsimplified
|
||||||
|
@ -4590,7 +4590,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
arraySize();
|
arraySize();
|
||||||
|
|
||||||
// The simplify enum might have inner loops
|
// The simplify enum might have inner loops
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Add std:: in front of std classes, when using namespace std; was given
|
// Add std:: in front of std classes, when using namespace std; was given
|
||||||
|
@ -4651,7 +4651,7 @@ bool Tokenizer::simplifyTokenList2()
|
||||||
|
|
||||||
simplifyStd();
|
simplifyStd();
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
simplifySizeof();
|
simplifySizeof();
|
||||||
|
@ -4664,7 +4664,7 @@ bool Tokenizer::simplifyTokenList2()
|
||||||
// e.g. const static int value = sizeof(X)/sizeof(Y);
|
// e.g. const static int value = sizeof(X)/sizeof(Y);
|
||||||
simplifyCalculations();
|
simplifyCalculations();
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Replace "*(ptr + num)" => "ptr[num]"
|
// Replace "*(ptr + num)" => "ptr[num]"
|
||||||
|
@ -4701,7 +4701,7 @@ bool Tokenizer::simplifyTokenList2()
|
||||||
|
|
||||||
bool modified = true;
|
bool modified = true;
|
||||||
while (modified) {
|
while (modified) {
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
modified = false;
|
modified = false;
|
||||||
|
@ -4764,7 +4764,7 @@ bool Tokenizer::simplifyTokenList2()
|
||||||
|
|
||||||
ValueFlow::setValues(&list, mSymbolDatabase, mErrorLogger, mSettings);
|
ValueFlow::setValues(&list, mSymbolDatabase, mErrorLogger, mSettings);
|
||||||
|
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
printDebugOutput(2);
|
printDebugOutput(2);
|
||||||
|
@ -5929,7 +5929,7 @@ bool Tokenizer::simplifyConstTernaryOp()
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
const Token *templateParameterEnd = nullptr; // The end of the current template parameter list, if any
|
const Token *templateParameterEnd = nullptr; // The end of the current template parameter list, if any
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (tok->str() == "<" && mTemplateSimplifier->templateParameters(tok))
|
if (tok->str() == "<" && TemplateSimplifier::templateParameters(tok))
|
||||||
templateParameterEnd = tok->findClosingBracket();
|
templateParameterEnd = tok->findClosingBracket();
|
||||||
if (tok == templateParameterEnd)
|
if (tok == templateParameterEnd)
|
||||||
templateParameterEnd = nullptr; // End of the current template parameter list
|
templateParameterEnd = nullptr; // End of the current template parameter list
|
||||||
|
@ -5943,7 +5943,7 @@ bool Tokenizer::simplifyConstTernaryOp()
|
||||||
const int offset = (tok->previous()->str() == ")") ? 2 : 1;
|
const int offset = (tok->previous()->str() == ")") ? 2 : 1;
|
||||||
|
|
||||||
if (tok->strAt(-2*offset) == "<") {
|
if (tok->strAt(-2*offset) == "<") {
|
||||||
if (isC() || !mTemplateSimplifier->templateParameters(tok->tokAt(-2*offset)))
|
if (isC() || !TemplateSimplifier::templateParameters(tok->tokAt(-2*offset)))
|
||||||
continue; // '<' is less than; the condition is not a constant
|
continue; // '<' is less than; the condition is not a constant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5983,7 +5983,7 @@ bool Tokenizer::simplifyConstTernaryOp()
|
||||||
for (const Token *endTok = colon; endTok; endTok = endTok->next()) {
|
for (const Token *endTok = colon; endTok; endTok = endTok->next()) {
|
||||||
if (Token::Match(endTok, "(|[|{"))
|
if (Token::Match(endTok, "(|[|{"))
|
||||||
endTok = endTok->link();
|
endTok = endTok->link();
|
||||||
else if (endTok->str() == "<" && (endTok->strAt(1) == ">" || mTemplateSimplifier->templateParameters(endTok)))
|
else if (endTok->str() == "<" && (endTok->strAt(1) == ">" || TemplateSimplifier::templateParameters(endTok)))
|
||||||
endTok = endTok->findClosingBracket();
|
endTok = endTok->findClosingBracket();
|
||||||
else if (endTok->str() == "?")
|
else if (endTok->str() == "?")
|
||||||
++ternaryOplevel;
|
++ternaryOplevel;
|
||||||
|
@ -6305,7 +6305,7 @@ void Tokenizer::simplifyPointerToStandardType()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Remove '[ 0 ]' suffix
|
// Remove '[ 0 ]' suffix
|
||||||
tok->next()->eraseTokens(tok->next(), tok->tokAt(5));
|
Token::eraseTokens(tok->next(), tok->tokAt(5));
|
||||||
// Remove '&' prefix
|
// Remove '&' prefix
|
||||||
tok = tok->previous();
|
tok = tok->previous();
|
||||||
if (!tok)
|
if (!tok)
|
||||||
|
@ -6561,7 +6561,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
|
||||||
|
|
||||||
//skip combinations of templates and namespaces
|
//skip combinations of templates and namespaces
|
||||||
while (!isC() && (Token::Match(tok2, "%type% <") || Token::Match(tok2, "%type% ::"))) {
|
while (!isC() && (Token::Match(tok2, "%type% <") || Token::Match(tok2, "%type% ::"))) {
|
||||||
if (tok2->next()->str() == "<" && !mTemplateSimplifier->templateParameters(tok2->next())) {
|
if (tok2->next()->str() == "<" && !TemplateSimplifier::templateParameters(tok2->next())) {
|
||||||
tok2 = nullptr;
|
tok2 = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6639,7 +6639,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
|
||||||
while (tok2 && tok2->str() != "," && tok2->str() != ";") {
|
while (tok2 && tok2->str() != "," && tok2->str() != ";") {
|
||||||
if (Token::Match(tok2, "{|(|["))
|
if (Token::Match(tok2, "{|(|["))
|
||||||
tok2 = tok2->link();
|
tok2 = tok2->link();
|
||||||
if (!isC() && tok2->str() == "<" && mTemplateSimplifier->templateParameters(tok2) > 0) {
|
if (!isC() && tok2->str() == "<" && TemplateSimplifier::templateParameters(tok2) > 0) {
|
||||||
tok2 = tok2->findClosingBracket();
|
tok2 = tok2->findClosingBracket();
|
||||||
}
|
}
|
||||||
if (!tok2)
|
if (!tok2)
|
||||||
|
@ -6704,7 +6704,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
|
||||||
if (tok2->str() == ",") {
|
if (tok2->str() == ",") {
|
||||||
tok2->str(";");
|
tok2->str(";");
|
||||||
//TODO: should we have to add also template '<>' links?
|
//TODO: should we have to add also template '<>' links?
|
||||||
list.insertTokens(tok2, type0, typelen);
|
TokenList::insertTokens(tok2, type0, typelen);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -6724,13 +6724,13 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
|
||||||
varTok = varTok->next();
|
varTok = varTok->next();
|
||||||
if (!varTok)
|
if (!varTok)
|
||||||
syntaxError(tok2); // invalid code
|
syntaxError(tok2); // invalid code
|
||||||
list.insertTokens(eq, varTok, 2);
|
TokenList::insertTokens(eq, varTok, 2);
|
||||||
eq->str(";");
|
eq->str(";");
|
||||||
|
|
||||||
// "= x, " => "= x; type "
|
// "= x, " => "= x; type "
|
||||||
if (tok2->str() == ",") {
|
if (tok2->str() == ",") {
|
||||||
tok2->str(";");
|
tok2->str(";");
|
||||||
list.insertTokens(tok2, type0, typelen);
|
TokenList::insertTokens(tok2, type0, typelen);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -7048,7 +7048,7 @@ void Tokenizer::simplifyInitVar()
|
||||||
tok1->str(";");
|
tok1->str(";");
|
||||||
|
|
||||||
const int numTokens = (Token::Match(tok, "class|struct|union")) ? 2U : 1U;
|
const int numTokens = (Token::Match(tok, "class|struct|union")) ? 2U : 1U;
|
||||||
list.insertTokens(tok1, tok, numTokens);
|
TokenList::insertTokens(tok1, tok, numTokens);
|
||||||
tok = initVar(tok);
|
tok = initVar(tok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7327,7 +7327,7 @@ bool Tokenizer::simplifyKnownVariables()
|
||||||
bool valueIsPointer = false;
|
bool valueIsPointer = false;
|
||||||
|
|
||||||
// there could be a hang here if tok2 is moved back by the function calls below for some reason
|
// there could be a hang here if tok2 is moved back by the function calls below for some reason
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!simplifyKnownVariablesGetData(varid, &tok2, &tok3, value, valueVarId, valueIsPointer, floatvars.find(tok2->varId()) != floatvars.end()))
|
if (!simplifyKnownVariablesGetData(varid, &tok2, &tok3, value, valueVarId, valueIsPointer, floatvars.find(tok2->varId()) != floatvars.end()))
|
||||||
|
@ -7360,7 +7360,7 @@ bool Tokenizer::simplifyKnownVariables()
|
||||||
ret |= simplifyKnownVariablesSimplify(&tok2, tok3, varid, emptyString, value, valueVarId, valueIsPointer, valueToken, indentlevel);
|
ret |= simplifyKnownVariablesSimplify(&tok2, tok3, varid, emptyString, value, valueVarId, valueIsPointer, valueToken, indentlevel);
|
||||||
|
|
||||||
// there could be a hang here if tok2 was moved back by the function call above for some reason
|
// there could be a hang here if tok2 was moved back by the function call above for some reason
|
||||||
if (mSettings->terminated())
|
if (Settings::terminated())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ private:
|
||||||
|
|
||||||
void run() OVERRIDE {
|
void run() OVERRIDE {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
while (!settings.library.ismemory(++id));
|
while (!Library::ismemory(++id));
|
||||||
settings.library.setalloc("malloc", id, -1);
|
settings.library.setalloc("malloc", id, -1);
|
||||||
settings.library.setrealloc("realloc", id, -1);
|
settings.library.setrealloc("realloc", id, -1);
|
||||||
settings.library.setdealloc("free", id, 1);
|
settings.library.setdealloc("free", id, 1);
|
||||||
while (!settings.library.isresource(++id));
|
while (!Library::isresource(++id));
|
||||||
settings.library.setalloc("fopen", id, -1);
|
settings.library.setalloc("fopen", id, -1);
|
||||||
settings.library.setrealloc("freopen", id, -1, 3);
|
settings.library.setrealloc("freopen", id, -1, 3);
|
||||||
settings.library.setdealloc("fclose", id, 1);
|
settings.library.setdealloc("fclose", id, 1);
|
||||||
|
|
|
@ -4336,7 +4336,7 @@ private:
|
||||||
for (unsigned i = 0 ; i < offset ; ++i)
|
for (unsigned i = 0 ; i < offset ; ++i)
|
||||||
_tok = _tok->next();
|
_tok = _tok->next();
|
||||||
|
|
||||||
const Token *tok1 = tokenizer.mTemplateSimplifier->findTemplateDeclarationEnd(_tok);
|
const Token *tok1 = TemplateSimplifier::findTemplateDeclarationEnd(_tok);
|
||||||
|
|
||||||
return (tok1 == Token::findsimplematch(tokenizer.list.front(), pattern));
|
return (tok1 == Token::findsimplematch(tokenizer.list.front(), pattern));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue