Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ Library::Container::Yield astFunctionYield(const Token* tok, const Settings* set
if (!tok)
return Library::Container::Yield::NO_YIELD;

if (!settings)
return Library::Container::Yield::NO_YIELD;

const auto* function = settings->library.getFunction(tok);
if (!function)
return Library::Container::Yield::NO_YIELD;
Expand Down
2 changes: 1 addition & 1 deletion lib/check64bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CPPCHECKLIB Check64BitPortability : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
Check64BitPortability check64BitPortability(&tokenizer, tokenizer.getSettings(), errorLogger);
Check64BitPortability check64BitPortability(&tokenizer, &tokenizer.getSettings(), errorLogger);
check64BitPortability.pointerassignment();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CPPCHECKLIB CheckAssert : public Check {

/** run checks, the token list is not simplified */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckAssert checkAssert(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckAssert checkAssert(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkAssert.assertWithSideEffects();
}

Expand Down
4 changes: 2 additions & 2 deletions lib/checkautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token
if (escape) {
if (getPointerDepth(tok) < getPointerDepth(tokvalue))
continue;
if (!ValueFlow::isLifetimeBorrowed(tok, mSettings))
if (!ValueFlow::isLifetimeBorrowed(tok, *mSettings))
continue;
if (tokvalue->exprId() == tok->exprId() && !(tok->variable() && tok->variable()->isArray()) &&
!astIsContainerView(tok->astParent()))
Expand Down Expand Up @@ -640,7 +640,7 @@ void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token
} else if (tok->variable() && tok->variable()->declarationId() == tok->varId()) {
var = tok->variable();
}
if (!ValueFlow::isLifetimeBorrowed(tok, mSettings))
if (!ValueFlow::isLifetimeBorrowed(tok, *mSettings))
continue;
const Token* nextTok = nextAfterAstRightmostLeaf(tok->astTop());
if (!nextTok)
Expand Down
2 changes: 1 addition & 1 deletion lib/checkautovariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CPPCHECKLIB CheckAutoVariables : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckAutoVariables checkAutoVariables(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckAutoVariables checkAutoVariables(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkAutoVariables.assignFunctionArg();
checkAutoVariables.checkVarLifetime();
checkAutoVariables.autoVariables();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkbool.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CPPCHECKLIB CheckBool : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckBool checkBool(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckBool checkBool(&tokenizer, &tokenizer.getSettings(), errorLogger);

// Checks
checkBool.checkComparisonOfBoolExpressionWithInt();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkboost.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CPPCHECKLIB CheckBoost : public Check {
if (!tokenizer.isCPP())
return;

CheckBoost checkBoost(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckBoost checkBoost(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkBoost.checkBoostForeachModification();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static bool getDimensionsEtc(const Token * const arrayToken, const Settings *set
return ChildrenToVisit::op1_and_op2;
});
}
} else if (const Token *stringLiteral = array->getValueTokenMinStrSize(settings, &path)) {
} else if (const Token *stringLiteral = array->getValueTokenMinStrSize(*settings, &path)) {
Dimension dim;
dim.tok = nullptr;
dim.num = Token::getStrArraySize(stringLiteral);
Expand Down
2 changes: 1 addition & 1 deletion lib/checkbufferoverrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CPPCHECKLIB CheckBufferOverrun : public Check {
: Check(myName(), tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckBufferOverrun checkBufferOverrun(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckBufferOverrun checkBufferOverrun(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkBufferOverrun.arrayIndex();
checkBufferOverrun.pointerArithmetic();
checkBufferOverrun.bufferOverflow();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CPPCHECKLIB CheckClass : public Check {
if (tokenizer.isC())
return;

CheckClass checkClass(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckClass checkClass(&tokenizer, &tokenizer.getSettings(), errorLogger);

// can't be a simplified check .. the 'sizeof' is used.
checkClass.checkMemset();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkcondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CPPCHECKLIB CheckCondition : public Check {
: Check(myName(), tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckCondition checkCondition(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckCondition checkCondition(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkCondition.multiCondition();
checkCondition.clarifyCondition(); // not simplified because ifAssign
checkCondition.multiCondition2();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkexceptionsafety.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CPPCHECKLIB CheckExceptionSafety : public Check {
if (tokenizer.isC())
return;

CheckExceptionSafety checkExceptionSafety(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckExceptionSafety checkExceptionSafety(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkExceptionSafety.destructors();
checkExceptionSafety.deallocThrow();
checkExceptionSafety.checkRethrowCopy();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void CheckFunctions::invalidFunctionUsage()
invalidFunctionArgStrError(argtok, functionToken->str(), argnr);
}
} else if (count > -1 && Token::Match(varTok, "= %str%")) {
const Token* strTok = varTok->getValueTokenMinStrSize(mSettings);
const Token* strTok = varTok->getValueTokenMinStrSize(*mSettings);
if (strTok) {
const int strSize = Token::getStrArraySize(strTok);
if (strSize > count && strTok->str().find('\0') == std::string::npos)
Expand Down
2 changes: 1 addition & 1 deletion lib/checkfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CPPCHECKLIB CheckFunctions : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckFunctions checkFunctions(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckFunctions checkFunctions(&tokenizer, &tokenizer.getSettings(), errorLogger);

checkFunctions.checkIgnoredReturnValue();
checkFunctions.checkMissingReturn(); // Missing "return" in exit path
Expand Down
4 changes: 2 additions & 2 deletions lib/checkinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class CPPCHECKLIB CheckInternal : public Check {
: Check(myName(), tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
if (!tokenizer.getSettings()->checks.isEnabled(Checks::internalCheck))
if (!tokenizer.getSettings().checks.isEnabled(Checks::internalCheck))
return;

CheckInternal checkInternal(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckInternal checkInternal(&tokenizer, &tokenizer.getSettings(), errorLogger);

checkInternal.checkTokenMatchPatterns();
checkInternal.checkTokenSimpleMatchPatterns();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CPPCHECKLIB CheckIO : public Check {

/** @brief Run checks on the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckIO checkIO(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckIO checkIO(&tokenizer, &tokenizer.getSettings(), errorLogger);

checkIO.checkWrongPrintfScanfArguments();
checkIO.checkCoutCerrMisusage();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkleakautovar.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
: Check(myName(), tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckLeakAutoVar checkLeakAutoVar(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckLeakAutoVar checkLeakAutoVar(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkLeakAutoVar.check();
}

Expand Down
8 changes: 4 additions & 4 deletions lib/checkmemoryleak.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class CPPCHECKLIB CheckMemoryLeakInFunction : public Check, public CheckMemoryLe
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {}

void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkMemoryLeak.checkReallocUsage();
}

Expand Down Expand Up @@ -234,7 +234,7 @@ class CPPCHECKLIB CheckMemoryLeakInClass : public Check, private CheckMemoryLeak
if (!tokenizer.isCPP())
return;

CheckMemoryLeakInClass checkMemoryLeak(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckMemoryLeakInClass checkMemoryLeak(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkMemoryLeak.check();
}

Expand Down Expand Up @@ -278,7 +278,7 @@ class CPPCHECKLIB CheckMemoryLeakStructMember : public Check, private CheckMemor
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {}

void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckMemoryLeakStructMember checkMemoryLeak(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckMemoryLeakStructMember checkMemoryLeak(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkMemoryLeak.check();
}

Expand Down Expand Up @@ -315,7 +315,7 @@ class CPPCHECKLIB CheckMemoryLeakNoVar : public Check, private CheckMemoryLeak {
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {}

void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckMemoryLeakNoVar checkMemoryLeak(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckMemoryLeakNoVar checkMemoryLeak(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkMemoryLeak.check();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checknullpointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class CPPCHECKLIB CheckNullPointer : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckNullPointer checkNullPointer(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckNullPointer checkNullPointer(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkNullPointer.nullPointer();
checkNullPointer.arithmetic();
checkNullPointer.nullConstantDereference();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkother.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CPPCHECKLIB CheckOther : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckOther checkOther(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckOther checkOther(&tokenizer, &tokenizer.getSettings(), errorLogger);

// Checks
checkOther.warningOldStylePointerCast();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkpostfixoperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CPPCHECKLIB CheckPostfixOperator : public Check {
if (tokenizer.isC())
return;

CheckPostfixOperator checkPostfixOperator(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckPostfixOperator checkPostfixOperator(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkPostfixOperator.postfixOperator();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checksizeof.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CPPCHECKLIB CheckSizeof : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer& tokenizer, ErrorLogger* errorLogger) override {
CheckSizeof checkSizeof(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckSizeof checkSizeof(&tokenizer, &tokenizer.getSettings(), errorLogger);

// Checks
checkSizeof.sizeofsizeof();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkstl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CPPCHECKLIB CheckStl : public Check {
return;
}

CheckStl checkStl(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckStl checkStl(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkStl.erase();
checkStl.if_find();
checkStl.checkFindInsert();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void CheckString::stringLiteralWrite()
for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
if (!tok->variable() || !tok->variable()->isPointer())
continue;
const Token *str = tok->getValueTokenMinStrSize(mSettings);
const Token *str = tok->getValueTokenMinStrSize(*mSettings);
if (!str)
continue;
if (Token::Match(tok, "%var% [") && Token::simpleMatch(tok->linkAt(1), "] ="))
Expand Down
2 changes: 1 addition & 1 deletion lib/checkstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CPPCHECKLIB CheckString : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckString checkString(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckString checkString(&tokenizer, &tokenizer.getSettings(), errorLogger);

// Checks
checkString.strPlusChar();
Expand Down
6 changes: 3 additions & 3 deletions lib/checktype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void CheckType::signConversionError(const Token *tok, const ValueFlow::Value *ne
//---------------------------------------------------------------------------
// Checking for long cast of int result const long x = var1 * var2;
//---------------------------------------------------------------------------
static bool checkTypeCombination(const ValueType& src, const ValueType& tgt, const Settings* settings)
static bool checkTypeCombination(const ValueType& src, const ValueType& tgt, const Settings& settings)
{
static const std::pair<ValueType::Type, ValueType::Type> typeCombinations[] = {
{ ValueType::Type::INT, ValueType::Type::LONG },
Expand Down Expand Up @@ -343,7 +343,7 @@ void CheckType::checkLongCast()

if (!lhstype || !rhstype)
continue;
if (!checkTypeCombination(*rhstype, *lhstype, mSettings))
if (!checkTypeCombination(*rhstype, *lhstype, *mSettings))
continue;

// assign int result to long/longlong const nonpointer?
Expand All @@ -370,7 +370,7 @@ void CheckType::checkLongCast()
if (tok->str() == "return") {
if (Token::Match(tok->astOperand1(), "<<|*")) {
const ValueType *type = tok->astOperand1()->valueType();
if (type && checkTypeCombination(*type, *retVt, mSettings) &&
if (type && checkTypeCombination(*type, *retVt, *mSettings) &&
type->pointer == 0U &&
type->originalTypeName.empty())
ret = tok;
Expand Down
2 changes: 1 addition & 1 deletion lib/checktype.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CPPCHECKLIB CheckType : public Check {
/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
// These are not "simplified" because casts can't be ignored
CheckType checkType(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckType checkType(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkType.checkTooBigBitwiseShift();
checkType.checkIntegerOverflow();
checkType.checkSignConversion();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkuninitvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CPPCHECKLIB CheckUninitVar : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckUninitVar checkUninitVar(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckUninitVar checkUninitVar(&tokenizer, &tokenizer.getSettings(), errorLogger);
checkUninitVar.valueFlowUninit();
checkUninitVar.check();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/checkunusedvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CPPCHECKLIB CheckUnusedVar : public Check {

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckUnusedVar checkUnusedVar(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckUnusedVar checkUnusedVar(&tokenizer, &tokenizer.getSettings(), errorLogger);

// Coding style checks
checkUnusedVar.checkStructMemberUsage();
Expand Down
2 changes: 1 addition & 1 deletion lib/checkvaarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CPPCHECKLIB CheckVaarg : public Check {
: Check(myName(), tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override {
CheckVaarg check(&tokenizer, tokenizer.getSettings(), errorLogger);
CheckVaarg check(&tokenizer, &tokenizer.getSettings(), errorLogger);
check.va_start_argument();
check.va_list_usage();
}
Expand Down
10 changes: 5 additions & 5 deletions lib/clangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ static void setTypes(TokenList &tokenList)

static void setValues(const Tokenizer &tokenizer, const SymbolDatabase *symbolDatabase)
{
const Settings * const settings = tokenizer.getSettings();
const Settings & settings = tokenizer.getSettings();

for (const Scope& scope : symbolDatabase->scopeList) {
if (!scope.definedType)
Expand All @@ -1537,15 +1537,15 @@ static void setValues(const Tokenizer &tokenizer, const SymbolDatabase *symbolDa
return v * dim.num;
});
if (var.valueType())
typeSize += mul * var.valueType()->typeSize(settings->platform, true);
typeSize += mul * var.valueType()->typeSize(settings.platform, true);
}
scope.definedType->sizeOf = typeSize;
}

for (auto *tok = const_cast<Token*>(tokenizer.tokens()); tok; tok = tok->next()) {
if (Token::simpleMatch(tok, "sizeof (")) {
ValueType vt = ValueType::parseDecl(tok->tokAt(2), *settings);
const int sz = vt.typeSize(settings->platform, true);
ValueType vt = ValueType::parseDecl(tok->tokAt(2), settings);
const int sz = vt.typeSize(settings.platform, true);
if (sz <= 0)
continue;
long long mul = 1;
Expand Down Expand Up @@ -1574,7 +1574,7 @@ void clangimport::parseClangAstDump(Tokenizer &tokenizer, std::istream &f)
symbolDatabase->scopeList.back().check = symbolDatabase;

clangimport::Data data;
data.mSettings = tokenizer.getSettings();
data.mSettings = &tokenizer.getSettings();
data.mSymbolDatabase = symbolDatabase;
std::string line;
std::vector<AstNodePtr> tree;
Expand Down
Loading