diff --git a/Makefile b/Makefile index ad9f84ee8ce..e2a15da9dc5 100644 --- a/Makefile +++ b/Makefile @@ -252,10 +252,19 @@ LIBOBJ = $(libcppdir)/valueflow.o \ $(libcppdir)/token.o \ $(libcppdir)/tokenlist.o \ $(libcppdir)/utils.o \ + $(libcppdir)/vf_array.o \ + $(libcppdir)/vf_bitand.o \ $(libcppdir)/vf_common.o \ + $(libcppdir)/vf_debug.o \ $(libcppdir)/vf_enumvalue.o \ + $(libcppdir)/vf_globalconstvar.o \ + $(libcppdir)/vf_globalstaticvar.o \ $(libcppdir)/vf_number.o \ + $(libcppdir)/vf_pointeralias.o \ + $(libcppdir)/vf_sameexpressions.o \ $(libcppdir)/vf_settokenvalue.o \ + $(libcppdir)/vf_string.o \ + $(libcppdir)/vf_unknownfunctionreturn.o \ $(libcppdir)/vfvalue.o EXTOBJ = externals/simplecpp/simplecpp.o \ @@ -464,7 +473,7 @@ validateRules: ###### Build -$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkuninitvar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/findtoken.h lib/forwardanalyzer.h lib/infer.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/programmemory.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vf_analyze.h lib/vf_common.h lib/vf_enumvalue.h lib/vf_number.h lib/vf_settokenvalue.h lib/vfvalue.h +$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkuninitvar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/findtoken.h lib/forwardanalyzer.h lib/infer.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/programmemory.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vf_analyze.h lib/vf_array.h lib/vf_bitand.h lib/vf_common.h lib/vf_debug.h lib/vf_enumvalue.h lib/vf_globalconstvar.h lib/vf_globalstaticvar.h lib/vf_number.h lib/vf_pointeralias.h lib/vf_sameexpressions.h lib/vf_settokenvalue.h lib/vf_string.h lib/vf_unknownfunctionreturn.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/valueflow.cpp $(libcppdir)/tokenize.o: lib/tokenize.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/astutils.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h @@ -650,18 +659,45 @@ $(libcppdir)/tokenlist.o: lib/tokenlist.cpp externals/simplecpp/simplecpp.h lib/ $(libcppdir)/utils.o: lib/utils.cpp lib/config.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/utils.cpp -$(libcppdir)/vf_common.o: lib/vf_common.cpp lib/addoninfo.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h +$(libcppdir)/vf_array.o: lib/vf_array.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_array.h lib/vf_settokenvalue.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_array.cpp + +$(libcppdir)/vf_bitand.o: lib/vf_bitand.cpp lib/config.h lib/errortypes.h lib/mathlib.h lib/sourcelocation.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_bitand.h lib/vf_settokenvalue.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_bitand.cpp + +$(libcppdir)/vf_common.o: lib/vf_common.cpp lib/addoninfo.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_common.cpp +$(libcppdir)/vf_debug.o: lib/vf_debug.cpp lib/addoninfo.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_common.h lib/vf_debug.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_debug.cpp + $(libcppdir)/vf_enumvalue.o: lib/vf_enumvalue.cpp lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/vf_enumvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_enumvalue.cpp +$(libcppdir)/vf_globalconstvar.o: lib/vf_globalconstvar.cpp lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_globalconstvar.h lib/vf_settokenvalue.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_globalconstvar.cpp + +$(libcppdir)/vf_globalstaticvar.o: lib/vf_globalstaticvar.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_globalstaticvar.h lib/vf_settokenvalue.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_globalstaticvar.cpp + $(libcppdir)/vf_number.o: lib/vf_number.cpp lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_common.h lib/vf_number.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_number.cpp +$(libcppdir)/vf_pointeralias.o: lib/vf_pointeralias.cpp lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_pointeralias.h lib/vf_settokenvalue.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_pointeralias.cpp + +$(libcppdir)/vf_sameexpressions.o: lib/vf_sameexpressions.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_sameexpressions.h lib/vf_settokenvalue.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_sameexpressions.cpp + $(libcppdir)/vf_settokenvalue.o: lib/vf_settokenvalue.cpp lib/addoninfo.h lib/astutils.h lib/calculate.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_settokenvalue.cpp +$(libcppdir)/vf_string.o: lib/vf_string.cpp lib/config.h lib/errortypes.h lib/mathlib.h lib/sourcelocation.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_settokenvalue.h lib/vf_string.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_string.cpp + +$(libcppdir)/vf_unknownfunctionreturn.o: lib/vf_unknownfunctionreturn.cpp lib/addoninfo.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vf_common.h lib/vf_settokenvalue.h lib/vf_unknownfunctionreturn.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_unknownfunctionreturn.cpp + $(libcppdir)/vfvalue.o: lib/vfvalue.cpp lib/config.h lib/errortypes.h lib/mathlib.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vfvalue.cpp diff --git a/lib/cppcheck.vcxproj b/lib/cppcheck.vcxproj index 1ec10c8dbe8..78171d08a45 100644 --- a/lib/cppcheck.vcxproj +++ b/lib/cppcheck.vcxproj @@ -87,10 +87,19 @@ + + + + + + + + + @@ -171,10 +180,19 @@ + + + + + + + + + diff --git a/lib/lib.pri b/lib/lib.pri index 45e0624dbf9..b2bcdf5c70f 100644 --- a/lib/lib.pri +++ b/lib/lib.pri @@ -78,10 +78,19 @@ HEADERS += $${PWD}/addoninfo.h \ $${PWD}/valueptr.h \ $${PWD}/version.h \ $${PWD}/vf_analyze.h \ + $${PWD}/vf_array.h \ + $${PWD}/vf_bitand.h \ $${PWD}/vf_common.h \ + $${PWD}/vf_debug.h \ $${PWD}/vf_enumvalue.h \ + $${PWD}/vf_globalconstvar.h \ + $${PWD}/vf_globalstaticvar.h \ $${PWD}/vf_number.h \ + $${PWD}/vf_pointeralias.h \ + $${PWD}/vf_sameexpressions.h \ $${PWD}/vf_settokenvalue.h \ + $${PWD}/vf_string.h \ + $${PWD}/vf_unknownfunctionreturn.h \ $${PWD}/vfvalue.h \ $${PWD}/xml.h @@ -147,8 +156,17 @@ SOURCES += $${PWD}/valueflow.cpp \ $${PWD}/token.cpp \ $${PWD}/tokenlist.cpp \ $${PWD}/utils.cpp \ + $${PWD}/vf_array.cpp \ + $${PWD}/vf_bitand.cpp \ $${PWD}/vf_common.cpp \ + $${PWD}/vf_debug.cpp \ $${PWD}/vf_enumvalue.cpp \ + $${PWD}/vf_globalconstvar.cpp \ + $${PWD}/vf_globalstaticvar.cpp \ $${PWD}/vf_number.cpp \ + $${PWD}/vf_pointeralias.cpp \ + $${PWD}/vf_sameexpressions.cpp \ $${PWD}/vf_settokenvalue.cpp \ + $${PWD}/vf_string.cpp \ + $${PWD}/vf_unknownfunctionreturn.cpp \ $${PWD}/vfvalue.cpp diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index d4f0f85bb52..da7ea11a51c 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -124,7 +124,6 @@ #include #include #include -#include #include #include #include @@ -541,75 +540,6 @@ size_t ValueFlow::getSizeOf(const ValueType &vt, const Settings &settings, int m return 0; } -static void valueFlowString(TokenList &tokenlist, const Settings& settings) -{ - for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { - if (tok->tokType() == Token::eString) { - ValueFlow::Value strvalue; - strvalue.valueType = ValueFlow::Value::ValueType::TOK; - strvalue.tokvalue = tok; - strvalue.setKnown(); - setTokenValue(tok, std::move(strvalue), settings); - } - } -} - -static void valueFlowArray(TokenList &tokenlist, const Settings &settings) -{ - std::map constantArrays; - - for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { - if (tok->varId() > 0) { - // array - const std::map::const_iterator it = constantArrays.find(tok->varId()); - if (it != constantArrays.end()) { - ValueFlow::Value value; - value.valueType = ValueFlow::Value::ValueType::TOK; - value.tokvalue = it->second; - value.setKnown(); - setTokenValue(tok, std::move(value), settings); - } - - // const array decl - else if (tok->variable() && tok->variable()->isArray() && tok->variable()->isConst() && - tok->variable()->nameToken() == tok && Token::Match(tok, "%var% [ %num%| ] = {")) { - Token* rhstok = tok->linkAt(1)->tokAt(2); - constantArrays[tok->varId()] = rhstok; - tok = rhstok->link(); - } - - // pointer = array - else if (tok->variable() && tok->variable()->isArray() && Token::simpleMatch(tok->astParent(), "=") && - astIsRHS(tok) && tok->astParent()->astOperand1() && - tok->astParent()->astOperand1()->variable() && - tok->astParent()->astOperand1()->variable()->isPointer()) { - ValueFlow::Value value; - value.valueType = ValueFlow::Value::ValueType::TOK; - value.tokvalue = tok; - value.setKnown(); - setTokenValue(tok, std::move(value), settings); - } - continue; - } - - if (Token::Match(tok, "const %type% %var% [ %num%| ] = {")) { - Token *vartok = tok->tokAt(2); - Token *rhstok = vartok->linkAt(1)->tokAt(2); - constantArrays[vartok->varId()] = rhstok; - tok = rhstok->link(); - continue; - } - - if (Token::Match(tok, "const char %var% [ %num%| ] = %str% ;")) { - Token *vartok = tok->tokAt(2); - Token *strtok = vartok->linkAt(1)->tokAt(2); - constantArrays[vartok->varId()] = strtok; - tok = strtok->next(); - continue; - } - } -} - static bool isNonZero(const Token *tok) { return tok && (!tok->hasKnownIntValue() || tok->values().front().intvalue != 0); @@ -738,104 +668,6 @@ static void valueFlowArrayElement(TokenList& tokenlist, const Settings& settings } } -static void valueFlowPointerAlias(TokenList &tokenlist, const Settings& settings) -{ - for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { - // not address of - if (!tok->isUnaryOp("&")) - continue; - - // parent should be a '=' - if (!Token::simpleMatch(tok->astParent(), "=")) - continue; - - // child should be some buffer or variable - const Token *vartok = tok->astOperand1(); - while (vartok) { - if (vartok->str() == "[") - vartok = vartok->astOperand1(); - else if (vartok->str() == "." || vartok->str() == "::") - vartok = vartok->astOperand2(); - else - break; - } - if (!(vartok && vartok->variable() && !vartok->variable()->isPointer())) - continue; - - ValueFlow::Value value; - value.valueType = ValueFlow::Value::ValueType::TOK; - value.tokvalue = tok; - setTokenValue(tok, std::move(value), settings); - } -} - -static void valueFlowBitAnd(TokenList &tokenlist, const Settings& settings) -{ - for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { - if (tok->str() != "&") - continue; - - if (tok->hasKnownValue()) - continue; - - if (!tok->astOperand1() || !tok->astOperand2()) - continue; - - MathLib::bigint number; - if (MathLib::isInt(tok->astOperand1()->str())) - number = MathLib::toBigNumber(tok->astOperand1()->str()); - else if (MathLib::isInt(tok->astOperand2()->str())) - number = MathLib::toBigNumber(tok->astOperand2()->str()); - else - continue; - - int bit = 0; - while (bit <= (MathLib::bigint_bits - 2) && ((((MathLib::bigint)1) << bit) < number)) - ++bit; - - if ((((MathLib::bigint)1) << bit) == number) { - setTokenValue(tok, ValueFlow::Value(0), settings); - setTokenValue(tok, ValueFlow::Value(number), settings); - } - } -} - -static void valueFlowSameExpressions(TokenList &tokenlist, const Settings& settings) -{ - for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { - if (tok->hasKnownIntValue()) - continue; - - if (!tok->astOperand1() || !tok->astOperand2()) - continue; - - if (tok->astOperand1()->isLiteral() || tok->astOperand2()->isLiteral()) - continue; - - if (!astIsIntegral(tok->astOperand1(), false) && !astIsIntegral(tok->astOperand2(), false)) - continue; - - ValueFlow::Value val; - - if (Token::Match(tok, "==|>=|<=|/")) { - val = ValueFlow::Value(1); - val.setKnown(); - } - - if (Token::Match(tok, "!=|>|<|%|-")) { - val = ValueFlow::Value(0); - val.setKnown(); - } - - if (!val.isKnown()) - continue; - - if (isSameExpression(false, tok->astOperand1(), tok->astOperand2(), settings, true, true, &val.errorPath)) { - setTokenValue(tok, std::move(val), settings); - } - } -} - static bool getExpressionRange(const Token *expr, MathLib::bigint *minvalue, MathLib::bigint *maxvalue) { if (expr->hasKnownIntValue()) { @@ -1095,88 +927,6 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett } } -static void valueFlowGlobalConstVar(TokenList& tokenList, const Settings &settings) -{ - // Get variable values... - std::map vars; - for (const Token* tok = tokenList.front(); tok; tok = tok->next()) { - if (!tok->variable()) - continue; - // Initialization... - if (tok == tok->variable()->nameToken() && - !tok->variable()->isVolatile() && - !tok->variable()->isArgument() && - tok->variable()->isConst() && - tok->valueType() && - tok->valueType()->isIntegral() && - tok->valueType()->pointer == 0 && - tok->valueType()->constness == 1 && - Token::Match(tok, "%name% =") && - tok->next()->astOperand2() && - tok->next()->astOperand2()->hasKnownIntValue()) { - vars[tok->variable()] = tok->next()->astOperand2()->values().front(); - } - } - - // Set values.. - for (Token* tok = tokenList.front(); tok; tok = tok->next()) { - if (!tok->variable()) - continue; - const std::map::const_iterator var = vars.find(tok->variable()); - if (var == vars.end()) - continue; - setTokenValue(tok, var->second, settings); - } -} - -static void valueFlowGlobalStaticVar(TokenList &tokenList, const Settings &settings) -{ - // Get variable values... - std::map vars; - for (const Token *tok = tokenList.front(); tok; tok = tok->next()) { - if (!tok->variable()) - continue; - // Initialization... - if (tok == tok->variable()->nameToken() && - tok->variable()->isStatic() && - !tok->variable()->isConst() && - tok->valueType() && - tok->valueType()->isIntegral() && - tok->valueType()->pointer == 0 && - tok->valueType()->constness == 0 && - Token::Match(tok, "%name% =") && - tok->next()->astOperand2() && - tok->next()->astOperand2()->hasKnownIntValue()) { - vars[tok->variable()] = tok->next()->astOperand2()->values().front(); - } else { - // If variable is written anywhere in TU then remove it from vars - if (!tok->astParent()) - continue; - if (Token::Match(tok->astParent(), "++|--|&") && !tok->astParent()->astOperand2()) - vars.erase(tok->variable()); - else if (tok->astParent()->isAssignmentOp()) { - if (tok == tok->astParent()->astOperand1()) - vars.erase(tok->variable()); - else if (tok->isCpp() && Token::Match(tok->astParent()->tokAt(-2), "& %name% =")) - vars.erase(tok->variable()); - } else if (isLikelyStreamRead(tok->astParent())) { - vars.erase(tok->variable()); - } else if (Token::Match(tok->astParent(), "[(,]")) - vars.erase(tok->variable()); - } - } - - // Set values.. - for (Token *tok = tokenList.front(); tok; tok = tok->next()) { - if (!tok->variable()) - continue; - const std::map::const_iterator var = vars.find(tok->variable()); - if (var == vars.end()) - continue; - setTokenValue(tok, var->second, settings); - } -} - static ValuePtr makeAnalyzer(const Token* exprTok, ValueFlow::Value value, const Settings& settings); static ValuePtr makeReverseAnalyzer(const Token* exprTok, ValueFlow::Value value, const Settings& settings); @@ -8255,18 +8005,6 @@ static void valueFlowDynamicBufferSize(const TokenList& tokenlist, const SymbolD } } -static bool getMinMaxValues(const std::string &typestr, const Settings &settings, bool cpp, MathLib::bigint &minvalue, MathLib::bigint &maxvalue) -{ - TokenList typeTokens(&settings); - std::istringstream istr(typestr+";"); - if (!typeTokens.createTokens(istr, cpp ? Standards::Language::CPP : Standards::Language::C)) - return false; - typeTokens.simplifyPlatformTypes(); - typeTokens.simplifyStdType(); - const ValueType &vt = ValueType::parseDecl(typeTokens.front(), settings); - return ValueFlow::getMinMaxValues(&vt, settings.platform, minvalue, maxvalue); -} - static void valueFlowSafeFunctions(const TokenList& tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger& errorLogger, const Settings& settings) { for (const Scope *functionScope : symboldatabase.functionScopes) { @@ -8365,54 +8103,6 @@ static void valueFlowSafeFunctions(const TokenList& tokenlist, const SymbolDatab } } -static void valueFlowUnknownFunctionReturn(TokenList &tokenlist, const Settings &settings) -{ - if (settings.checkUnknownFunctionReturn.empty()) - return; - for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { - if (!tok->astParent() || tok->str() != "(" || !tok->previous()->isName()) - continue; - if (settings.checkUnknownFunctionReturn.find(tok->strAt(-1)) == settings.checkUnknownFunctionReturn.end()) - continue; - std::vector unknownValues = settings.library.unknownReturnValues(tok->astOperand1()); - if (unknownValues.empty()) - continue; - - // Get min/max values for return type - const std::string &typestr = settings.library.returnValueType(tok->previous()); - MathLib::bigint minvalue, maxvalue; - if (!getMinMaxValues(typestr, settings, tok->isCpp(), minvalue, maxvalue)) - continue; - - for (MathLib::bigint value : unknownValues) { - if (value < minvalue) - value = minvalue; - else if (value > maxvalue) - value = maxvalue; - setTokenValue(tok, ValueFlow::Value(value), settings); - } - } -} - -static void valueFlowDebug(TokenList& tokenlist, ErrorLogger& errorLogger, const Settings& settings) -{ - if (!settings.debugnormal && !settings.debugwarnings) - return; - for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { - if (tok->getTokenDebug() != TokenDebug::ValueFlow) - continue; - if (tok->astParent() && tok->astParent()->getTokenDebug() == TokenDebug::ValueFlow) - continue; - for (const ValueFlow::Value& v : tok->values()) { - std::string msg = "The value is " + debugString(v); - ErrorPath errorPath = v.errorPath; - errorPath.insert(errorPath.end(), v.debugPath.cbegin(), v.debugPath.cend()); - errorPath.emplace_back(tok, ""); - errorLogger.reportErr({errorPath, &tokenlist, Severity::debug, "valueFlow", msg, CWE{0}, Certainty::normal}); - } - } -} - const ValueFlow::Value *ValueFlow::valueFlowConstantFoldAST(Token *expr, const Settings &settings) { if (expr && expr->values().empty()) { @@ -8636,17 +8326,17 @@ void ValueFlow::setValues(TokenList& tokenlist, runner.run_once({ VFA(analyzeEnumValue(symboldatabase, settings)), VFA(analyzeNumber(tokenlist, settings)), - VFA(valueFlowString(tokenlist, settings)), - VFA(valueFlowArray(tokenlist, settings)), - VFA(valueFlowUnknownFunctionReturn(tokenlist, settings)), - VFA(valueFlowGlobalConstVar(tokenlist, settings)), + VFA(analyzeString(tokenlist, settings)), + VFA(analyzeArray(tokenlist, settings)), + VFA(analyzeUnknownFunctionReturn(tokenlist, settings)), + VFA(analyzeGlobalConstVar(tokenlist, settings)), VFA(analyzeEnumValue(symboldatabase, settings)), - VFA(valueFlowGlobalStaticVar(tokenlist, settings)), - VFA(valueFlowPointerAlias(tokenlist, settings)), + VFA(analyzeGlobalStaticVar(tokenlist, settings)), + VFA(analyzePointerAlias(tokenlist, settings)), VFA(valueFlowLifetime(tokenlist, errorLogger, settings)), VFA(valueFlowSymbolic(tokenlist, symboldatabase, errorLogger, settings)), - VFA(valueFlowBitAnd(tokenlist, settings)), - VFA(valueFlowSameExpressions(tokenlist, settings)), + VFA(analyzeBitAnd(tokenlist, settings)), + VFA(analyzeSameExpressions(tokenlist, settings)), VFA(valueFlowConditionExpressions(tokenlist, symboldatabase, errorLogger, settings)), }); @@ -8683,7 +8373,7 @@ void ValueFlow::setValues(TokenList& tokenlist, runner.run_once({ VFA(valueFlowDynamicBufferSize(tokenlist, symboldatabase, errorLogger, settings)), - VFA(valueFlowDebug(tokenlist, errorLogger, settings)), + VFA(analyzeDebug(tokenlist, errorLogger, settings)), }); } diff --git a/lib/vf_analyze.h b/lib/vf_analyze.h index 41608a06ede..6ad7b910f2b 100644 --- a/lib/vf_analyze.h +++ b/lib/vf_analyze.h @@ -19,7 +19,16 @@ #ifndef vfAnalyzeH #define vfAnalyzeH +#include "vf_array.h" // IWYU pragma: export +#include "vf_bitand.h" // IWYU pragma: export +#include "vf_debug.h" // IWYU pragma: export #include "vf_enumvalue.h" // IWYU pragma: export +#include "vf_globalconstvar.h" // IWYU pragma: export +#include "vf_globalstaticvar.h" // IWYU pragma: export #include "vf_number.h" // IWYU pragma: export +#include "vf_pointeralias.h" // IWYU pragma: export +#include "vf_sameexpressions.h" // IWYU pragma: export +#include "vf_string.h" // IWYU pragma: export +#include "vf_unknownfunctionreturn.h" // IWYU pragma: export #endif // vfAnalyzeH diff --git a/lib/vf_array.cpp b/lib/vf_array.cpp new file mode 100644 index 00000000000..1fd14a9bff4 --- /dev/null +++ b/lib/vf_array.cpp @@ -0,0 +1,90 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_array.h" + +#include "astutils.h" +#include "config.h" +#include "symboldatabase.h" +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_settokenvalue.h" + +#include +#include + +namespace ValueFlow +{ + void analyzeArray(TokenList &tokenlist, const Settings &settings) + { + std::map constantArrays; + + for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { + if (tok->varId() > 0) { + // array + const std::map::const_iterator it = constantArrays.find(tok->varId()); + if (it != constantArrays.end()) { + Value value; + value.valueType = Value::ValueType::TOK; + value.tokvalue = it->second; + value.setKnown(); + setTokenValue(tok, std::move(value), settings); + } + + // const array decl + else if (tok->variable() && tok->variable()->isArray() && tok->variable()->isConst() && + tok->variable()->nameToken() == tok && Token::Match(tok, "%var% [ %num%| ] = {")) { + Token* rhstok = tok->linkAt(1)->tokAt(2); + constantArrays[tok->varId()] = rhstok; + tok = rhstok->link(); + } + + // pointer = array + else if (tok->variable() && tok->variable()->isArray() && Token::simpleMatch(tok->astParent(), "=") && + astIsRHS(tok) && tok->astParent()->astOperand1() && + tok->astParent()->astOperand1()->variable() && + tok->astParent()->astOperand1()->variable()->isPointer()) { + Value value; + value.valueType = Value::ValueType::TOK; + value.tokvalue = tok; + value.setKnown(); + setTokenValue(tok, std::move(value), settings); + } + continue; + } + + if (Token::Match(tok, "const %type% %var% [ %num%| ] = {")) { + Token *vartok = tok->tokAt(2); + Token *rhstok = vartok->linkAt(1)->tokAt(2); + constantArrays[vartok->varId()] = rhstok; + tok = rhstok->link(); + continue; + } + + if (Token::Match(tok, "const char %var% [ %num%| ] = %str% ;")) { + Token *vartok = tok->tokAt(2); + Token *strtok = vartok->linkAt(1)->tokAt(2); + constantArrays[vartok->varId()] = strtok; + tok = strtok->next(); + continue; + } + } + } +} diff --git a/lib/vf_array.h b/lib/vf_array.h new file mode 100644 index 00000000000..a7ef79c7e79 --- /dev/null +++ b/lib/vf_array.h @@ -0,0 +1,30 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfArrayH +#define vfArrayH + +class TokenList; +class Settings; + +namespace ValueFlow +{ + void analyzeArray(TokenList &tokenlist, const Settings &settings); +} + +#endif // vfArrayH diff --git a/lib/vf_bitand.cpp b/lib/vf_bitand.cpp new file mode 100644 index 00000000000..89a7405dcd0 --- /dev/null +++ b/lib/vf_bitand.cpp @@ -0,0 +1,62 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_bitand.h" + +#include "mathlib.h" +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_settokenvalue.h" + +#include + +namespace ValueFlow +{ + void analyzeBitAnd(TokenList &tokenlist, const Settings& settings) + { + for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { + if (tok->str() != "&") + continue; + + if (tok->hasKnownValue()) + continue; + + if (!tok->astOperand1() || !tok->astOperand2()) + continue; + + MathLib::bigint number; + if (MathLib::isInt(tok->astOperand1()->str())) + number = MathLib::toBigNumber(tok->astOperand1()->str()); + else if (MathLib::isInt(tok->astOperand2()->str())) + number = MathLib::toBigNumber(tok->astOperand2()->str()); + else + continue; + + int bit = 0; + while (bit <= (MathLib::bigint_bits - 2) && ((((MathLib::bigint)1) << bit) < number)) + ++bit; + + if ((((MathLib::bigint)1) << bit) == number) { + setTokenValue(tok, Value(0), settings); + setTokenValue(tok, Value(number), settings); + } + } + } +} diff --git a/lib/vf_bitand.h b/lib/vf_bitand.h new file mode 100644 index 00000000000..df958254291 --- /dev/null +++ b/lib/vf_bitand.h @@ -0,0 +1,30 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfBitAndH +#define vfBitAndH + +class TokenList; +class Settings; + +namespace ValueFlow +{ + void analyzeBitAnd(TokenList &tokenlist, const Settings& settings); +} + +#endif // vfBitAndH diff --git a/lib/vf_common.cpp b/lib/vf_common.cpp index ae1f4a43d8f..a65a173651d 100644 --- a/lib/vf_common.cpp +++ b/lib/vf_common.cpp @@ -25,6 +25,7 @@ #include "standards.h" #include "symboldatabase.h" #include "token.h" +#include "tokenlist.h" #include "valueflow.h" #include "vf_settokenvalue.h" @@ -33,6 +34,7 @@ #include #include #include +#include #include #include @@ -93,6 +95,18 @@ namespace ValueFlow return true; } + bool getMinMaxValues(const std::string &typestr, const Settings &settings, bool cpp, MathLib::bigint &minvalue, MathLib::bigint &maxvalue) + { + TokenList typeTokens(&settings); + std::istringstream istr(typestr+";"); + if (!typeTokens.createTokens(istr, cpp ? Standards::Language::CPP : Standards::Language::C)) + return false; + typeTokens.simplifyPlatformTypes(); + typeTokens.simplifyStdType(); + const ValueType &vt = ValueType::parseDecl(typeTokens.front(), settings); + return getMinMaxValues(&vt, settings.platform, minvalue, maxvalue); + } + long long truncateIntValue(long long value, size_t value_size, const ValueType::Sign dst_sign) { if (value_size == 0) diff --git a/lib/vf_common.h b/lib/vf_common.h index d67dfc6e722..fc9b7e137af 100644 --- a/lib/vf_common.h +++ b/lib/vf_common.h @@ -35,6 +35,8 @@ namespace ValueFlow { bool getMinMaxValues(const ValueType* vt, const Platform& platform, MathLib::bigint& minValue, MathLib::bigint& maxValue); + bool getMinMaxValues(const std::string &typestr, const Settings &settings, bool cpp, MathLib::bigint &minvalue, MathLib::bigint &maxvalue); + long long truncateIntValue(long long value, size_t value_size, const ValueType::Sign dst_sign); Token * valueFlowSetConstantValue(Token *tok, const Settings &settings); diff --git a/lib/vf_debug.cpp b/lib/vf_debug.cpp new file mode 100644 index 00000000000..9bc54af31b8 --- /dev/null +++ b/lib/vf_debug.cpp @@ -0,0 +1,53 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_debug.h" + +#include "errorlogger.h" +#include "errortypes.h" +#include "settings.h" +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_common.h" + +#include +#include + +namespace ValueFlow +{ + void analyzeDebug(TokenList& tokenlist, ErrorLogger& errorLogger, const Settings& settings) + { + if (!settings.debugnormal && !settings.debugwarnings) + return; + for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { + if (tok->getTokenDebug() != TokenDebug::ValueFlow) + continue; + if (tok->astParent() && tok->astParent()->getTokenDebug() == TokenDebug::ValueFlow) + continue; + for (const Value& v : tok->values()) { + std::string msg = "The value is " + debugString(v); + ErrorPath errorPath = v.errorPath; + errorPath.insert(errorPath.end(), v.debugPath.cbegin(), v.debugPath.cend()); + errorPath.emplace_back(tok, ""); + errorLogger.reportErr({errorPath, &tokenlist, Severity::debug, "valueFlow", msg, CWE{0}, Certainty::normal}); + } + } + } +} diff --git a/lib/vf_debug.h b/lib/vf_debug.h new file mode 100644 index 00000000000..8e5de01db1a --- /dev/null +++ b/lib/vf_debug.h @@ -0,0 +1,31 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfDebugH +#define vfDebugH + +class TokenList; +class ErrorLogger; +class Settings; + +namespace ValueFlow +{ + void analyzeDebug(TokenList& tokenlist, ErrorLogger& errorLogger, const Settings& settings); +} + +#endif // vfDebugH diff --git a/lib/vf_globalconstvar.cpp b/lib/vf_globalconstvar.cpp new file mode 100644 index 00000000000..47cd59adb30 --- /dev/null +++ b/lib/vf_globalconstvar.cpp @@ -0,0 +1,67 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_globalconstvar.h" + +#include "symboldatabase.h" +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_settokenvalue.h" + +#include +#include +#include + +namespace ValueFlow +{ + void analyzeGlobalConstVar(TokenList& tokenList, const Settings &settings) + { + // Get variable values... + std::map vars; + for (const Token* tok = tokenList.front(); tok; tok = tok->next()) { + if (!tok->variable()) + continue; + // Initialization... + if (tok == tok->variable()->nameToken() && + !tok->variable()->isVolatile() && + !tok->variable()->isArgument() && + tok->variable()->isConst() && + tok->valueType() && + tok->valueType()->isIntegral() && + tok->valueType()->pointer == 0 && + tok->valueType()->constness == 1 && + Token::Match(tok, "%name% =") && + tok->next()->astOperand2() && + tok->next()->astOperand2()->hasKnownIntValue()) { + vars[tok->variable()] = tok->next()->astOperand2()->values().front(); + } + } + + // Set values.. + for (Token* tok = tokenList.front(); tok; tok = tok->next()) { + if (!tok->variable()) + continue; + const std::map::const_iterator var = vars.find(tok->variable()); + if (var == vars.end()) + continue; + setTokenValue(tok, var->second, settings); + } + } +} diff --git a/lib/vf_globalconstvar.h b/lib/vf_globalconstvar.h new file mode 100644 index 00000000000..b0f79ae68f9 --- /dev/null +++ b/lib/vf_globalconstvar.h @@ -0,0 +1,30 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfGlobalConstVarH +#define vfGlobalConstVarH + +class TokenList; +class Settings; + +namespace ValueFlow +{ + void analyzeGlobalConstVar(TokenList& tokenList, const Settings &settings); +} + +#endif // vfGlobalConstVarH diff --git a/lib/vf_globalstaticvar.cpp b/lib/vf_globalstaticvar.cpp new file mode 100644 index 00000000000..545850c9baf --- /dev/null +++ b/lib/vf_globalstaticvar.cpp @@ -0,0 +1,82 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_globalstaticvar.h" + +#include "astutils.h" +#include "symboldatabase.h" +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_settokenvalue.h" + +#include +#include +#include + +namespace ValueFlow +{ + void analyzeGlobalStaticVar(TokenList &tokenList, const Settings &settings) + { + // Get variable values... + std::map vars; + for (const Token *tok = tokenList.front(); tok; tok = tok->next()) { + if (!tok->variable()) + continue; + // Initialization... + if (tok == tok->variable()->nameToken() && + tok->variable()->isStatic() && + !tok->variable()->isConst() && + tok->valueType() && + tok->valueType()->isIntegral() && + tok->valueType()->pointer == 0 && + tok->valueType()->constness == 0 && + Token::Match(tok, "%name% =") && + tok->next()->astOperand2() && + tok->next()->astOperand2()->hasKnownIntValue()) { + vars[tok->variable()] = tok->next()->astOperand2()->values().front(); + } else { + // If variable is written anywhere in TU then remove it from vars + if (!tok->astParent()) + continue; + if (Token::Match(tok->astParent(), "++|--|&") && !tok->astParent()->astOperand2()) + vars.erase(tok->variable()); + else if (tok->astParent()->isAssignmentOp()) { + if (tok == tok->astParent()->astOperand1()) + vars.erase(tok->variable()); + else if (tok->isCpp() && Token::Match(tok->astParent()->tokAt(-2), "& %name% =")) + vars.erase(tok->variable()); + } else if (isLikelyStreamRead(tok->astParent())) { + vars.erase(tok->variable()); + } else if (Token::Match(tok->astParent(), "[(,]")) + vars.erase(tok->variable()); + } + } + + // Set values.. + for (Token *tok = tokenList.front(); tok; tok = tok->next()) { + if (!tok->variable()) + continue; + const std::map::const_iterator var = vars.find(tok->variable()); + if (var == vars.end()) + continue; + setTokenValue(tok, var->second, settings); + } + } +} diff --git a/lib/vf_globalstaticvar.h b/lib/vf_globalstaticvar.h new file mode 100644 index 00000000000..8e0cdbc16b4 --- /dev/null +++ b/lib/vf_globalstaticvar.h @@ -0,0 +1,30 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfGlobalStaticVarH +#define vfGlobalStaticVarH + +class TokenList; +class Settings; + +namespace ValueFlow +{ + void analyzeGlobalStaticVar(TokenList &tokenList, const Settings &settings); +} + +#endif // vfGlobalStaticVarH diff --git a/lib/vf_pointeralias.cpp b/lib/vf_pointeralias.cpp new file mode 100644 index 00000000000..225f87872e4 --- /dev/null +++ b/lib/vf_pointeralias.cpp @@ -0,0 +1,63 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_pointeralias.h" + +#include "symboldatabase.h" +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_settokenvalue.h" + +#include +#include + +namespace ValueFlow +{ + void analyzePointerAlias(TokenList &tokenlist, const Settings& settings) + { + for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { + // not address of + if (!tok->isUnaryOp("&")) + continue; + + // parent should be a '=' + if (!Token::simpleMatch(tok->astParent(), "=")) + continue; + + // child should be some buffer or variable + const Token *vartok = tok->astOperand1(); + while (vartok) { + if (vartok->str() == "[") + vartok = vartok->astOperand1(); + else if (vartok->str() == "." || vartok->str() == "::") + vartok = vartok->astOperand2(); + else + break; + } + if (!(vartok && vartok->variable() && !vartok->variable()->isPointer())) + continue; + + Value value; + value.valueType = Value::ValueType::TOK; + value.tokvalue = tok; + setTokenValue(tok, std::move(value), settings); + } + } +} diff --git a/lib/vf_pointeralias.h b/lib/vf_pointeralias.h new file mode 100644 index 00000000000..8ef12c37146 --- /dev/null +++ b/lib/vf_pointeralias.h @@ -0,0 +1,30 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfPointerAliasH +#define vfPointerAliasH + +class TokenList; +class Settings; + +namespace ValueFlow +{ + void analyzePointerAlias(TokenList &tokenlist, const Settings& settings); +} + +#endif // vfPointerAliasH diff --git a/lib/vf_sameexpressions.cpp b/lib/vf_sameexpressions.cpp new file mode 100644 index 00000000000..2aca4453e6f --- /dev/null +++ b/lib/vf_sameexpressions.cpp @@ -0,0 +1,67 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_sameexpressions.h" + +#include "astutils.h" +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_settokenvalue.h" + +#include + +namespace ValueFlow +{ + void analyzeSameExpressions(TokenList &tokenlist, const Settings& settings) + { + for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { + if (tok->hasKnownIntValue()) + continue; + + if (!tok->astOperand1() || !tok->astOperand2()) + continue; + + if (tok->astOperand1()->isLiteral() || tok->astOperand2()->isLiteral()) + continue; + + if (!astIsIntegral(tok->astOperand1(), false) && !astIsIntegral(tok->astOperand2(), false)) + continue; + + Value val; + + if (Token::Match(tok, "==|>=|<=|/")) { + val = ValueFlow::Value(1); + val.setKnown(); + } + + if (Token::Match(tok, "!=|>|<|%|-")) { + val = ValueFlow::Value(0); + val.setKnown(); + } + + if (!val.isKnown()) + continue; + + if (isSameExpression(false, tok->astOperand1(), tok->astOperand2(), settings, true, true, &val.errorPath)) { + setTokenValue(tok, std::move(val), settings); + } + } + } +} diff --git a/lib/vf_sameexpressions.h b/lib/vf_sameexpressions.h new file mode 100644 index 00000000000..d8dbe209c2f --- /dev/null +++ b/lib/vf_sameexpressions.h @@ -0,0 +1,30 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfSameExpressionsH +#define vfSameExpressionsH + +class TokenList; +class Settings; + +namespace ValueFlow +{ + void analyzeSameExpressions(TokenList &tokenlist, const Settings& settings); +} + +#endif // vfSameExpressionsH diff --git a/lib/vf_string.cpp b/lib/vf_string.cpp new file mode 100644 index 00000000000..b472279369b --- /dev/null +++ b/lib/vf_string.cpp @@ -0,0 +1,43 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_string.h" + +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_settokenvalue.h" + +#include + +namespace ValueFlow +{ + void analyzeString(TokenList &tokenlist, const Settings& settings) + { + for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { + if (tok->tokType() == Token::eString) { + Value strvalue; + strvalue.valueType = Value::ValueType::TOK; + strvalue.tokvalue = tok; + strvalue.setKnown(); + setTokenValue(tok, std::move(strvalue), settings); + } + } + } +} diff --git a/lib/vf_string.h b/lib/vf_string.h new file mode 100644 index 00000000000..b899fbcb25e --- /dev/null +++ b/lib/vf_string.h @@ -0,0 +1,30 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfStringH +#define vfStringH + +class TokenList; +class Settings; + +namespace ValueFlow +{ + void analyzeString(TokenList &tokenlist, const Settings& settings); +} + +#endif // vfStringH diff --git a/lib/vf_unknownfunctionreturn.cpp b/lib/vf_unknownfunctionreturn.cpp new file mode 100644 index 00000000000..8577b3b173c --- /dev/null +++ b/lib/vf_unknownfunctionreturn.cpp @@ -0,0 +1,65 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vf_unknownfunctionreturn.h" + +#include "library.h" +#include "mathlib.h" +#include "settings.h" +#include "token.h" +#include "tokenlist.h" +#include "vfvalue.h" + +#include "vf_common.h" +#include "vf_settokenvalue.h" + +#include +#include +#include + +namespace ValueFlow +{ + void analyzeUnknownFunctionReturn(TokenList &tokenlist, const Settings &settings) + { + if (settings.checkUnknownFunctionReturn.empty()) + return; + for (Token *tok = tokenlist.front(); tok; tok = tok->next()) { + if (!tok->astParent() || tok->str() != "(" || !tok->previous()->isName()) + continue; + if (settings.checkUnknownFunctionReturn.find(tok->strAt(-1)) == settings.checkUnknownFunctionReturn.end()) + continue; + std::vector unknownValues = settings.library.unknownReturnValues(tok->astOperand1()); + if (unknownValues.empty()) + continue; + + // Get min/max values for return type + const std::string &typestr = settings.library.returnValueType(tok->previous()); + MathLib::bigint minvalue, maxvalue; + if (!getMinMaxValues(typestr, settings, tok->isCpp(), minvalue, maxvalue)) + continue; + + for (MathLib::bigint value : unknownValues) { + if (value < minvalue) + value = minvalue; + else if (value > maxvalue) + value = maxvalue; + setTokenValue(tok, Value(value), settings); + } + } + } +} diff --git a/lib/vf_unknownfunctionreturn.h b/lib/vf_unknownfunctionreturn.h new file mode 100644 index 00000000000..1de8072e4d2 --- /dev/null +++ b/lib/vf_unknownfunctionreturn.h @@ -0,0 +1,30 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2024 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef vfUnknownFunctionReturnH +#define vfUnknownFunctionReturnH + +class TokenList; +class Settings; + +namespace ValueFlow +{ + void analyzeUnknownFunctionReturn(TokenList &tokenlist, const Settings &settings); +} + +#endif // vfUnknownFunctionReturnH diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index 30559784264..bd46c392669 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -95,10 +95,19 @@ LIBOBJ = $(libcppdir)/valueflow.o \ $(libcppdir)/token.o \ $(libcppdir)/tokenlist.o \ $(libcppdir)/utils.o \ + $(libcppdir)/vf_array.o \ + $(libcppdir)/vf_bitand.o \ $(libcppdir)/vf_common.o \ + $(libcppdir)/vf_debug.o \ $(libcppdir)/vf_enumvalue.o \ + $(libcppdir)/vf_globalconstvar.o \ + $(libcppdir)/vf_globalstaticvar.o \ $(libcppdir)/vf_number.o \ + $(libcppdir)/vf_pointeralias.o \ + $(libcppdir)/vf_sameexpressions.o \ $(libcppdir)/vf_settokenvalue.o \ + $(libcppdir)/vf_string.o \ + $(libcppdir)/vf_unknownfunctionreturn.o \ $(libcppdir)/vfvalue.o EXTOBJ = simplecpp.o \ @@ -143,7 +152,7 @@ simplecpp.o: ../externals/simplecpp/simplecpp.cpp ../externals/simplecpp/simplec tinyxml2.o: ../externals/tinyxml2/tinyxml2.cpp ../externals/tinyxml2/tinyxml2.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -w -c -o $@ ../externals/tinyxml2/tinyxml2.cpp -$(libcppdir)/valueflow.o: ../lib/valueflow.cpp ../lib/addoninfo.h ../lib/analyzer.h ../lib/astutils.h ../lib/calculate.h ../lib/check.h ../lib/checkuninitvar.h ../lib/color.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/findtoken.h ../lib/forwardanalyzer.h ../lib/infer.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/programmemory.h ../lib/reverseanalyzer.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/timer.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/valueptr.h ../lib/vf_analyze.h ../lib/vf_common.h ../lib/vf_enumvalue.h ../lib/vf_number.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h +$(libcppdir)/valueflow.o: ../lib/valueflow.cpp ../lib/addoninfo.h ../lib/analyzer.h ../lib/astutils.h ../lib/calculate.h ../lib/check.h ../lib/checkuninitvar.h ../lib/color.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/findtoken.h ../lib/forwardanalyzer.h ../lib/infer.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/programmemory.h ../lib/reverseanalyzer.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/timer.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/valueptr.h ../lib/vf_analyze.h ../lib/vf_array.h ../lib/vf_bitand.h ../lib/vf_common.h ../lib/vf_debug.h ../lib/vf_enumvalue.h ../lib/vf_globalconstvar.h ../lib/vf_globalstaticvar.h ../lib/vf_number.h ../lib/vf_pointeralias.h ../lib/vf_sameexpressions.h ../lib/vf_settokenvalue.h ../lib/vf_string.h ../lib/vf_unknownfunctionreturn.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/valueflow.cpp $(libcppdir)/tokenize.o: ../lib/tokenize.cpp ../externals/simplecpp/simplecpp.h ../lib/addoninfo.h ../lib/astutils.h ../lib/color.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/preprocessor.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/summaries.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/timer.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/vfvalue.h @@ -329,18 +338,45 @@ $(libcppdir)/tokenlist.o: ../lib/tokenlist.cpp ../externals/simplecpp/simplecpp. $(libcppdir)/utils.o: ../lib/utils.cpp ../lib/config.h ../lib/utils.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/utils.cpp -$(libcppdir)/vf_common.o: ../lib/vf_common.cpp ../lib/addoninfo.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/valueflow.h ../lib/vf_common.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h +$(libcppdir)/vf_array.o: ../lib/vf_array.cpp ../lib/astutils.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_array.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_array.cpp + +$(libcppdir)/vf_bitand.o: ../lib/vf_bitand.cpp ../lib/config.h ../lib/errortypes.h ../lib/mathlib.h ../lib/sourcelocation.h ../lib/standards.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_bitand.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_bitand.cpp + +$(libcppdir)/vf_common.o: ../lib/vf_common.cpp ../lib/addoninfo.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/settings.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/vf_common.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_common.cpp +$(libcppdir)/vf_debug.o: ../lib/vf_debug.cpp ../lib/addoninfo.h ../lib/color.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_common.h ../lib/vf_debug.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_debug.cpp + $(libcppdir)/vf_enumvalue.o: ../lib/vf_enumvalue.cpp ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/valueflow.h ../lib/vf_enumvalue.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_enumvalue.cpp +$(libcppdir)/vf_globalconstvar.o: ../lib/vf_globalconstvar.cpp ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_globalconstvar.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_globalconstvar.cpp + +$(libcppdir)/vf_globalstaticvar.o: ../lib/vf_globalstaticvar.cpp ../lib/astutils.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_globalstaticvar.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_globalstaticvar.cpp + $(libcppdir)/vf_number.o: ../lib/vf_number.cpp ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_common.h ../lib/vf_number.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_number.cpp +$(libcppdir)/vf_pointeralias.o: ../lib/vf_pointeralias.cpp ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_pointeralias.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_pointeralias.cpp + +$(libcppdir)/vf_sameexpressions.o: ../lib/vf_sameexpressions.cpp ../lib/astutils.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_sameexpressions.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_sameexpressions.cpp + $(libcppdir)/vf_settokenvalue.o: ../lib/vf_settokenvalue.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/calculate.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/valueflow.h ../lib/vf_common.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_settokenvalue.cpp +$(libcppdir)/vf_string.o: ../lib/vf_string.cpp ../lib/config.h ../lib/errortypes.h ../lib/mathlib.h ../lib/sourcelocation.h ../lib/standards.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_settokenvalue.h ../lib/vf_string.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_string.cpp + +$(libcppdir)/vf_unknownfunctionreturn.o: ../lib/vf_unknownfunctionreturn.cpp ../lib/addoninfo.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/vf_common.h ../lib/vf_settokenvalue.h ../lib/vf_unknownfunctionreturn.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_unknownfunctionreturn.cpp + $(libcppdir)/vfvalue.o: ../lib/vfvalue.cpp ../lib/config.h ../lib/errortypes.h ../lib/mathlib.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vfvalue.cpp