MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / minmaxCompare

Function minmaxCompare

lib/checkstl.cpp:2822–2834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2820}
2821
2822static std::string minmaxCompare(const Token *condTok, nonneg int loopVar, nonneg int assignVar, LoopType loopType, bool invert = false)
2823{
2824 if (loopType == LoopType::RANGE && !hasVarIds(condTok, loopVar, assignVar))
2825 return "std::accumulate";
2826 std::string algo = "std::max_element";
2827 if (Token::Match(condTok, "<|<="))
2828 algo = "std::min_element";
2829 if (condTok->astOperand1()->varId() == assignVar)
2830 algo = flipMinMax(algo);
2831 if (invert)
2832 algo = flipMinMax(algo);
2833 return algo;
2834}
2835
2836static bool isTernaryAssignment(const Token* assignTok, nonneg int loopVarId, nonneg int assignVarId, LoopType loopType, std::string& algo)
2837{

Callers 1

isTernaryAssignmentFunction · 0.85

Calls 3

hasVarIdsFunction · 0.85
flipMinMaxFunction · 0.85
astOperand1Method · 0.80

Tested by

no test coverage detected