diff --git a/Makefile b/Makefile index 35298d8ea39..86d570923de 100644 --- a/Makefile +++ b/Makefile @@ -270,10 +270,12 @@ LIBOBJ = $(libcppdir)/valueflow.o \ $(libcppdir)/vf_iterators.o \ $(libcppdir)/vf_number.o \ $(libcppdir)/vf_pointeralias.o \ + $(libcppdir)/vf_reverse.o \ $(libcppdir)/vf_rightshift.o \ $(libcppdir)/vf_sameexpressions.o \ $(libcppdir)/vf_settokenvalue.o \ $(libcppdir)/vf_string.o \ + $(libcppdir)/vf_switchvariable.o \ $(libcppdir)/vf_symbolicinfer.o \ $(libcppdir)/vf_unknownfunctionreturn.o \ $(libcppdir)/vfvalue.o @@ -485,7 +487,7 @@ validateRules: ###### Build -$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.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/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_analyzers.h lib/vf_array.h lib/vf_arraybool.h lib/vf_arrayelement.h lib/vf_bailout.h lib/vf_bitand.h lib/vf_common.h lib/vf_debug.h lib/vf_enumvalue.h lib/vf_functionreturn.h lib/vf_globalconstvar.h lib/vf_globalstaticvar.h lib/vf_impossiblevalues.h lib/vf_infercondition.h lib/vf_iteratorinfer.h lib/vf_iterators.h lib/vf_number.h lib/vf_pointeralias.h lib/vf_rightshift.h lib/vf_sameexpressions.h lib/vf_settokenvalue.h lib/vf_string.h lib/vf_symbolicinfer.h lib/vf_unknownfunctionreturn.h lib/vfvalue.h +$(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.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/platform.h lib/programmemory.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_analyzers.h lib/vf_array.h lib/vf_arraybool.h lib/vf_arrayelement.h lib/vf_bailout.h lib/vf_bitand.h lib/vf_common.h lib/vf_debug.h lib/vf_enumvalue.h lib/vf_functionreturn.h lib/vf_globalconstvar.h lib/vf_globalstaticvar.h lib/vf_impossiblevalues.h lib/vf_infercondition.h lib/vf_iteratorinfer.h lib/vf_iterators.h lib/vf_number.h lib/vf_pointeralias.h lib/vf_reverse.h lib/vf_rightshift.h lib/vf_sameexpressions.h lib/vf_settokenvalue.h lib/vf_string.h lib/vf_switchvariable.h lib/vf_symbolicinfer.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 @@ -725,6 +727,9 @@ $(libcppdir)/vf_number.o: lib/vf_number.cpp lib/config.h lib/errortypes.h lib/li $(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_reverse.o: lib/vf_reverse.cpp lib/addoninfo.h lib/analyzer.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/reverseanalyzer.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/valueptr.h lib/vf_analyzers.h lib/vf_common.h lib/vf_reverse.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_reverse.cpp + $(libcppdir)/vf_rightshift.o: lib/vf_rightshift.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_rightshift.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_rightshift.cpp @@ -737,6 +742,9 @@ $(libcppdir)/vf_settokenvalue.o: lib/vf_settokenvalue.cpp lib/addoninfo.h lib/as $(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_switchvariable.o: lib/vf_switchvariable.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/utils.h lib/vf_bailout.h lib/vf_reverse.h lib/vf_switchvariable.h lib/vfvalue.h + $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_switchvariable.cpp + $(libcppdir)/vf_symbolicinfer.o: lib/vf_symbolicinfer.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/infer.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/utils.h lib/valueptr.h lib/vf_settokenvalue.h lib/vf_symbolicinfer.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_symbolicinfer.cpp diff --git a/lib/cppcheck.vcxproj b/lib/cppcheck.vcxproj index 7439f69795d..01002a2226a 100644 --- a/lib/cppcheck.vcxproj +++ b/lib/cppcheck.vcxproj @@ -105,10 +105,12 @@ + + @@ -211,10 +213,12 @@ + + diff --git a/lib/lib.pri b/lib/lib.pri index 2765845d151..2edc3d8ff00 100644 --- a/lib/lib.pri +++ b/lib/lib.pri @@ -98,10 +98,12 @@ HEADERS += $${PWD}/addoninfo.h \ $${PWD}/vf_iterators.h \ $${PWD}/vf_number.h \ $${PWD}/vf_pointeralias.h \ + $${PWD}/vf_reverse.h \ $${PWD}/vf_rightshift.h \ $${PWD}/vf_sameexpressions.h \ $${PWD}/vf_settokenvalue.h \ $${PWD}/vf_string.h \ + $${PWD}/vf_switchvariable.h \ $${PWD}/vf_symbolicinfer.h \ $${PWD}/vf_unknownfunctionreturn.h \ $${PWD}/vfvalue.h \ @@ -187,10 +189,12 @@ SOURCES += $${PWD}/valueflow.cpp \ $${PWD}/vf_iterators.cpp \ $${PWD}/vf_number.cpp \ $${PWD}/vf_pointeralias.cpp \ + $${PWD}/vf_reverse.cpp \ $${PWD}/vf_rightshift.cpp \ $${PWD}/vf_sameexpressions.cpp \ $${PWD}/vf_settokenvalue.cpp \ $${PWD}/vf_string.cpp \ + $${PWD}/vf_switchvariable.cpp \ $${PWD}/vf_symbolicinfer.cpp \ $${PWD}/vf_unknownfunctionreturn.cpp \ $${PWD}/vfvalue.cpp diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ba1e85fd9d8..37e05e9ced3 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -90,7 +90,6 @@ #include "mathlib.h" #include "platform.h" #include "programmemory.h" -#include "reverseanalyzer.h" #include "settings.h" #include "smallvector.h" #include "sourcelocation.h" @@ -107,6 +106,7 @@ #include "vf_analyzers.h" #include "vf_bailout.h" #include "vf_common.h" +#include "vf_reverse.h" #include "vf_settokenvalue.h" #include @@ -593,34 +593,6 @@ static Analyzer::Result valueFlowForwardRecursive(Token* top, return result; } -static void valueFlowReverse(Token* tok, - const Token* const endToken, - const Token* const varToken, - std::list values, - const TokenList& tokenlist, - ErrorLogger& errorLogger, - const Settings& settings, - SourceLocation loc = SourceLocation::current()) -{ - for (ValueFlow::Value& v : values) { - if (settings.debugnormal) - setSourceLocation(v, loc, tok); - valueFlowGenericReverse(tok, endToken, makeReverseAnalyzer(varToken, std::move(v), settings), tokenlist, errorLogger, settings); - } -} - -// Deprecated -static void valueFlowReverse(const TokenList& tokenlist, - Token* tok, - const Token* const varToken, - ValueFlow::Value val, - ErrorLogger& errorLogger, - const Settings& settings, - SourceLocation loc = SourceLocation::current()) -{ - valueFlowReverse(tok, nullptr, varToken, {std::move(val)}, tokenlist, errorLogger, settings, loc); -} - static bool isConditionKnown(const Token* tok, bool then) { const char* op = "||"; @@ -4552,78 +4524,6 @@ static void valueFlowInjectParameter(const TokenList& tokenlist, settings); } -static void valueFlowSwitchVariable(const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger &errorLogger, const Settings &settings) -{ - for (const Scope &scope : symboldatabase.scopeList) { - if (scope.type != Scope::ScopeType::eSwitch) - continue; - if (!Token::Match(scope.classDef, "switch ( %var% ) {")) - continue; - const Token *vartok = scope.classDef->tokAt(2); - const Variable *var = vartok->variable(); - if (!var) - continue; - - // bailout: global non-const variables - if (!(var->isLocal() || var->isArgument()) && !var->isConst()) { - if (settings.debugwarnings) - bailout(tokenlist, errorLogger, vartok, "switch variable " + var->name() + " is global"); - continue; - } - - for (const Token *tok = scope.bodyStart->next(); tok != scope.bodyEnd; tok = tok->next()) { - if (tok->str() == "{") { - tok = tok->link(); - continue; - } - if (Token::Match(tok, "case %num% :")) { - std::list values; - values.emplace_back(MathLib::toBigNumber(tok->strAt(1))); - values.back().condition = tok; - values.back().errorPath.emplace_back(tok, "case " + tok->strAt(1) + ": " + vartok->str() + " is " + tok->strAt(1) + " here."); - bool known = false; - if ((Token::simpleMatch(tok->previous(), "{") || Token::simpleMatch(tok->tokAt(-2), "break ;")) && !Token::Match(tok->tokAt(3), ";| case")) - known = true; - while (Token::Match(tok->tokAt(3), ";| case %num% :")) { - known = false; - tok = tok->tokAt(3); - if (!tok->isName()) - tok = tok->next(); - values.emplace_back(MathLib::toBigNumber(tok->strAt(1))); - values.back().condition = tok; - values.back().errorPath.emplace_back(tok, "case " + tok->strAt(1) + ": " + vartok->str() + " is " + tok->strAt(1) + " here."); - } - for (auto val = values.cbegin(); val != values.cend(); ++val) { - valueFlowReverse(tokenlist, - const_cast(scope.classDef), - vartok, - *val, - errorLogger, - settings); - } - if (vartok->variable()->scope()) { - if (known) - values.back().setKnown(); - - // FIXME We must check if there is a return. See #9276 - /* - valueFlowForwardVariable(tok->tokAt(3), - vartok->variable()->scope()->bodyEnd, - vartok->variable(), - vartok->varId(), - values, - values.back().isKnown(), - false, - tokenlist, - errorLogger, - settings); - */ - } - } - } - } -} - static std::list getFunctionArgumentValues(const Token *argtok) { std::list argvalues(argtok->values()); @@ -6122,7 +6022,7 @@ void ValueFlow::setValues(TokenList& tokenlist, VFA_CPP(valueFlowAfterSwap(tokenlist, symboldatabase, errorLogger, settings)), VFA(valueFlowCondition(SimpleConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions)), VFA(analyzeInferCondition(tokenlist, settings)), - VFA(valueFlowSwitchVariable(tokenlist, symboldatabase, errorLogger, settings)), + VFA(analyzeSwitchVariable(tokenlist, symboldatabase, errorLogger, settings)), VFA(valueFlowForLoop(tokenlist, symboldatabase, errorLogger, settings)), VFA(valueFlowSubFunction(tokenlist, symboldatabase, errorLogger, settings)), VFA(analyzeFunctionReturn(tokenlist, errorLogger, settings)), diff --git a/lib/vf_analyze.h b/lib/vf_analyze.h index 72b321743f1..22458a2b187 100644 --- a/lib/vf_analyze.h +++ b/lib/vf_analyze.h @@ -37,6 +37,7 @@ #include "vf_rightshift.h" // IWYU pragma: export #include "vf_sameexpressions.h" // IWYU pragma: export #include "vf_string.h" // IWYU pragma: export +#include "vf_switchvariable.h" // IWYU pragma: export #include "vf_symbolicinfer.h" // IWYU pragma: export #include "vf_unknownfunctionreturn.h" // IWYU pragma: export diff --git a/lib/vf_reverse.cpp b/lib/vf_reverse.cpp new file mode 100644 index 00000000000..f72d157f38c --- /dev/null +++ b/lib/vf_reverse.cpp @@ -0,0 +1,47 @@ +/* + * 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_reverse.h" + +#include "reverseanalyzer.h" +#include "settings.h" +#include "vfvalue.h" + +#include "vf_analyzers.h" +#include "vf_common.h" + +#include + +namespace ValueFlow +{ + void valueFlowReverse(Token* tok, + const Token* const endToken, + const Token* const varToken, + std::list values, + const TokenList& tokenlist, + ErrorLogger& errorLogger, + const Settings& settings, + SourceLocation loc) + { + for (Value& v : values) { + if (settings.debugnormal) + setSourceLocation(v, loc, tok); + valueFlowGenericReverse(tok, endToken, makeReverseAnalyzer(varToken, std::move(v), settings), tokenlist, errorLogger, settings); + } + } +} diff --git a/lib/vf_reverse.h b/lib/vf_reverse.h new file mode 100644 index 00000000000..a3db45ea03a --- /dev/null +++ b/lib/vf_reverse.h @@ -0,0 +1,47 @@ +/* -*- C++ -*- + * 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 vfReverseeH +#define vfReverseeH + +#include "sourcelocation.h" + +#include + +class TokenList; +class ErrorLogger; +class Settings; +class Token; +namespace ValueFlow +{ + class Value; +} + +namespace ValueFlow { + void valueFlowReverse(Token* tok, + const Token* const endToken, + const Token* const varToken, + std::list values, + const TokenList& tokenlist, + ErrorLogger& errorLogger, + const Settings& settings, + SourceLocation loc = SourceLocation::current()); + +} + +#endif // vfReverseeH diff --git a/lib/vf_switchvariable.cpp b/lib/vf_switchvariable.cpp new file mode 100644 index 00000000000..463522095bd --- /dev/null +++ b/lib/vf_switchvariable.cpp @@ -0,0 +1,120 @@ +/* + * 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_switchvariable.h" + +#include "mathlib.h" +#include "settings.h" +#include "sourcelocation.h" +#include "symboldatabase.h" +#include "token.h" +#include "vfvalue.h" + +#include "vf_bailout.h" +#include "vf_reverse.h" + +#include +#include +#include + +namespace ValueFlow +{ + // Deprecated + static void valueFlowReverse(const TokenList& tokenlist, + Token* tok, + const Token* const varToken, + Value val, + ErrorLogger& errorLogger, + const Settings& settings, + SourceLocation loc = SourceLocation::current()) + { + valueFlowReverse(tok, nullptr, varToken, {std::move(val)}, tokenlist, errorLogger, settings, loc); + } + + void analyzeSwitchVariable(const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger &errorLogger, const Settings &settings) + { + for (const Scope &scope : symboldatabase.scopeList) { + if (scope.type != Scope::ScopeType::eSwitch) + continue; + if (!Token::Match(scope.classDef, "switch ( %var% ) {")) + continue; + const Token *vartok = scope.classDef->tokAt(2); + const Variable *var = vartok->variable(); + if (!var) + continue; + + // bailout: global non-const variables + if (!(var->isLocal() || var->isArgument()) && !var->isConst()) { + if (settings.debugwarnings) + bailout(tokenlist, errorLogger, vartok, "switch variable " + var->name() + " is global"); + continue; + } + + for (const Token *tok = scope.bodyStart->next(); tok != scope.bodyEnd; tok = tok->next()) { + if (tok->str() == "{") { + tok = tok->link(); + continue; + } + if (Token::Match(tok, "case %num% :")) { + std::list values; + values.emplace_back(MathLib::toBigNumber(tok->strAt(1))); + values.back().condition = tok; + values.back().errorPath.emplace_back(tok, "case " + tok->strAt(1) + ": " + vartok->str() + " is " + tok->strAt(1) + " here."); + bool known = false; + if ((Token::simpleMatch(tok->previous(), "{") || Token::simpleMatch(tok->tokAt(-2), "break ;")) && !Token::Match(tok->tokAt(3), ";| case")) + known = true; + while (Token::Match(tok->tokAt(3), ";| case %num% :")) { + known = false; + tok = tok->tokAt(3); + if (!tok->isName()) + tok = tok->next(); + values.emplace_back(MathLib::toBigNumber(tok->strAt(1))); + values.back().condition = tok; + values.back().errorPath.emplace_back(tok, "case " + tok->strAt(1) + ": " + vartok->str() + " is " + tok->strAt(1) + " here."); + } + for (auto val = values.cbegin(); val != values.cend(); ++val) { + valueFlowReverse(tokenlist, + const_cast(scope.classDef), + vartok, + *val, + errorLogger, + settings); + } + if (vartok->variable()->scope()) { + if (known) + values.back().setKnown(); + + // FIXME We must check if there is a return. See #9276 + /* + valueFlowForwardVariable(tok->tokAt(3), + vartok->variable()->scope()->bodyEnd, + vartok->variable(), + vartok->varId(), + values, + values.back().isKnown(), + false, + tokenlist, + errorLogger, + settings); + */ + } + } + } + } + } +} diff --git a/lib/vf_switchvariable.h b/lib/vf_switchvariable.h new file mode 100644 index 00000000000..251ff71b143 --- /dev/null +++ b/lib/vf_switchvariable.h @@ -0,0 +1,32 @@ +/* -*- C++ -*- + * 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 vfSwitchVariableH +#define vfSwitchVariableH + +class TokenList; +class SymbolDatabase; +class ErrorLogger; +class Settings; + +namespace ValueFlow +{ + void analyzeSwitchVariable(const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger &errorLogger, const Settings &settings); +} + +#endif // vfSwitchVariableH diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index bf367a1913a..1617744674b 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -113,10 +113,12 @@ LIBOBJ = $(libcppdir)/valueflow.o \ $(libcppdir)/vf_iterators.o \ $(libcppdir)/vf_number.o \ $(libcppdir)/vf_pointeralias.o \ + $(libcppdir)/vf_reverse.o \ $(libcppdir)/vf_rightshift.o \ $(libcppdir)/vf_sameexpressions.o \ $(libcppdir)/vf_settokenvalue.o \ $(libcppdir)/vf_string.o \ + $(libcppdir)/vf_switchvariable.o \ $(libcppdir)/vf_symbolicinfer.o \ $(libcppdir)/vf_unknownfunctionreturn.o \ $(libcppdir)/vfvalue.o @@ -163,7 +165,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/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/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_analyzers.h ../lib/vf_array.h ../lib/vf_arraybool.h ../lib/vf_arrayelement.h ../lib/vf_bailout.h ../lib/vf_bitand.h ../lib/vf_common.h ../lib/vf_debug.h ../lib/vf_enumvalue.h ../lib/vf_functionreturn.h ../lib/vf_globalconstvar.h ../lib/vf_globalstaticvar.h ../lib/vf_impossiblevalues.h ../lib/vf_infercondition.h ../lib/vf_iteratorinfer.h ../lib/vf_iterators.h ../lib/vf_number.h ../lib/vf_pointeralias.h ../lib/vf_rightshift.h ../lib/vf_sameexpressions.h ../lib/vf_settokenvalue.h ../lib/vf_string.h ../lib/vf_symbolicinfer.h ../lib/vf_unknownfunctionreturn.h ../lib/vfvalue.h +$(libcppdir)/valueflow.o: ../lib/valueflow.cpp ../lib/addoninfo.h ../lib/analyzer.h ../lib/astutils.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/platform.h ../lib/programmemory.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_analyzers.h ../lib/vf_array.h ../lib/vf_arraybool.h ../lib/vf_arrayelement.h ../lib/vf_bailout.h ../lib/vf_bitand.h ../lib/vf_common.h ../lib/vf_debug.h ../lib/vf_enumvalue.h ../lib/vf_functionreturn.h ../lib/vf_globalconstvar.h ../lib/vf_globalstaticvar.h ../lib/vf_impossiblevalues.h ../lib/vf_infercondition.h ../lib/vf_iteratorinfer.h ../lib/vf_iterators.h ../lib/vf_number.h ../lib/vf_pointeralias.h ../lib/vf_reverse.h ../lib/vf_rightshift.h ../lib/vf_sameexpressions.h ../lib/vf_settokenvalue.h ../lib/vf_string.h ../lib/vf_switchvariable.h ../lib/vf_symbolicinfer.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 @@ -403,6 +405,9 @@ $(libcppdir)/vf_number.o: ../lib/vf_number.cpp ../lib/config.h ../lib/errortypes $(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_reverse.o: ../lib/vf_reverse.cpp ../lib/addoninfo.h ../lib/analyzer.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/reverseanalyzer.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/valueptr.h ../lib/vf_analyzers.h ../lib/vf_common.h ../lib/vf_reverse.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_reverse.cpp + $(libcppdir)/vf_rightshift.o: ../lib/vf_rightshift.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_rightshift.h ../lib/vf_settokenvalue.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_rightshift.cpp @@ -415,6 +420,9 @@ $(libcppdir)/vf_settokenvalue.o: ../lib/vf_settokenvalue.cpp ../lib/addoninfo.h $(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_switchvariable.o: ../lib/vf_switchvariable.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/utils.h ../lib/vf_bailout.h ../lib/vf_reverse.h ../lib/vf_switchvariable.h ../lib/vfvalue.h + $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_switchvariable.cpp + $(libcppdir)/vf_symbolicinfer.o: ../lib/vf_symbolicinfer.cpp ../lib/astutils.h ../lib/config.h ../lib/errortypes.h ../lib/infer.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/utils.h ../lib/valueptr.h ../lib/vf_settokenvalue.h ../lib/vf_symbolicinfer.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_symbolicinfer.cpp