Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert valueflow split #6991

Merged
merged 19 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 2 additions & 98 deletions Makefile

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,8 @@ bool extractForLoopValues(const Token *forToken,
const Token *incExpr = forToken->next()->astOperand2()->astOperand2()->astOperand2();
if (!initExpr || !initExpr->isBinaryOp() || initExpr->str() != "=" || !Token::Match(initExpr->astOperand1(), "%var%"))
return false;
std::vector<MathLib::bigint> minInitValue = getMinValue(makeIntegralInferModel(), initExpr->astOperand2()->values());
std::vector<MathLib::bigint> minInitValue =
getMinValue(makeIntegralInferModel(), initExpr->astOperand2()->values());
if (minInitValue.empty()) {
const ValueFlow::Value* v = initExpr->astOperand2()->getMinValue(true);
if (v)
Expand Down
48 changes: 0 additions & 48 deletions lib/cppcheck.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,10 @@
<ClCompile Include="tokenlist.cpp" />
<ClCompile Include="utils.cpp" />
<ClCompile Include="vf_analyzers.cpp" />
<ClCompile Include="vf_array.cpp" />
<ClCompile Include="vf_arraybool.cpp" />
<ClCompile Include="vf_arrayelement.cpp" />
<ClCompile Include="vf_bailout.cpp" />
<ClCompile Include="vf_bitand.cpp" />
<ClCompile Include="vf_common.cpp" />
<ClCompile Include="vf_conditionexpressions.cpp" />
<ClCompile Include="vf_debug.cpp" />
<ClCompile Include="vf_enumvalue.cpp" />
<ClCompile Include="vf_functionreturn.cpp" />
<ClCompile Include="vf_globalconstvar.cpp" />
<ClCompile Include="vf_globalstaticvar.cpp" />
<ClCompile Include="vf_impossiblevalues.cpp" />
<ClCompile Include="vf_infercondition.cpp" />
<ClCompile Include="vf_iteratorinfer.cpp" />
<ClCompile Include="vf_iterators.cpp" />
<ClCompile Include="vf_number.cpp" />
<ClCompile Include="vf_pointeralias.cpp" />
<ClCompile Include="vf_reverse.cpp" />
<ClCompile Include="vf_rightshift.cpp" />
<ClCompile Include="vf_sameexpressions.cpp" />
<ClCompile Include="vf_settokenvalue.cpp" />
<ClCompile Include="vf_string.cpp" />
<ClCompile Include="vf_subfunction.cpp" />
<ClCompile Include="vf_switchvariable.cpp" />
<ClCompile Include="vf_symbolicinfer.cpp" />
<ClCompile Include="vf_symbolicoperators.cpp" />
<ClCompile Include="vf_unknownfunctionreturn.cpp" />
<ClCompile Include="vfvalue.cpp" />
</ItemGroup>
<ItemGroup Label="HeaderFiles">
Expand Down Expand Up @@ -202,34 +178,10 @@
<ClInclude Include="version.h" />
<ClInclude Include="vf_analyze.h" />
<ClInclude Include="vf_analyzers.h" />
<ClInclude Include="vf_array.h" />
<ClInclude Include="vf_arraybool.h" />
<ClInclude Include="vf_arrayelement.h" />
<ClInclude Include="vf_bailout.h" />
<ClInclude Include="vf_bitand.h" />
<ClInclude Include="vf_common.h" />
<ClInclude Include="vf_conditionexpressions.h" />
<ClInclude Include="vf_debug.h" />
<ClInclude Include="vf_enumvalue.h" />
<ClInclude Include="vf_functionreturn.h" />
<ClInclude Include="vf_globalconstvar.h" />
<ClInclude Include="vf_globalstaticvar.h" />
<ClInclude Include="vf_impossiblevalues.h" />
<ClInclude Include="vf_infercondition.h" />
<ClInclude Include="vf_iteratorinfer.h" />
<ClInclude Include="vf_iterators.h" />
<ClInclude Include="vf_number.h" />
<ClInclude Include="vf_pointeralias.h" />
<ClInclude Include="vf_reverse.h" />
<ClInclude Include="vf_rightshift.h" />
<ClInclude Include="vf_sameexpressions.h" />
<ClInclude Include="vf_settokenvalue.h" />
<ClInclude Include="vf_string.h" />
<ClInclude Include="vf_subfunction.h" />
<ClInclude Include="vf_switchvariable.h" />
<ClInclude Include="vf_symbolicinfer.h" />
<ClInclude Include="vf_symbolicoperators.h" />
<ClInclude Include="vf_unknownfunctionreturn.h" />
<ClInclude Include="vfvalue.h" />
<ClInclude Include="xml.h" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions lib/infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <unordered_set>
#include <utility>

class Token;

template<class Predicate, class Compare>
static const ValueFlow::Value* getCompareValue(const std::list<ValueFlow::Value>& values, Predicate pred, Compare compare)
{
Expand Down
1 change: 0 additions & 1 deletion lib/infer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <string>
#include <vector>

class Token;
template<class T> class ValuePtr;

struct InferModel {
Expand Down
12 changes: 8 additions & 4 deletions lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,14 +1523,18 @@ namespace {
r = evaluate(expr->str(), lhs, rhs);
if (expr->isComparisonOp() && (r.isUninitValue() || r.isImpossible())) {
if (rhs.isIntValue() && !expr->astOperand1()->values().empty()) {
std::vector<ValueFlow::Value> result =
infer(makeIntegralInferModel(), expr->str(), expr->astOperand1()->values(), {std::move(rhs)});
std::vector<ValueFlow::Value> result = infer(makeIntegralInferModel(),
expr->str(),
expr->astOperand1()->values(),
{std::move(rhs)});
if (!result.empty() && result.front().isKnown())
return std::move(result.front());
}
if (lhs.isIntValue() && !expr->astOperand2()->values().empty()) {
std::vector<ValueFlow::Value> result =
infer(makeIntegralInferModel(), expr->str(), {std::move(lhs)}, expr->astOperand2()->values());
std::vector<ValueFlow::Value> result = infer(makeIntegralInferModel(),
expr->str(),
{std::move(lhs)},
expr->astOperand2()->values());
if (!result.empty() && result.front().isKnown())
return std::move(result.front());
}
Expand Down
Loading
Loading