Skip to content

Commit 981c9b5

Browse files
committed
added bailout message TODOs
1 parent ef97334 commit 981c9b5

6 files changed

Lines changed: 21 additions & 17 deletions

File tree

lib/astutils.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int findArgumentPosRecursive(const Token* tok, const Token* tokToFind, b
6969
{
7070
++depth;
7171
if (!tok || depth >= 100)
72-
return -1;
72+
return -1; // TODO: add bailout message
7373
if (tok->str() == ",") {
7474
int res = findArgumentPosRecursive(tok->astOperand1(), tokToFind, found, depth);
7575
if (res == -1)
@@ -112,7 +112,7 @@ static void astFlattenCopy(T* tok, const char* op, OuputIterator out, int depth
112112
{
113113
--depth;
114114
if (!tok || depth < 0)
115-
return;
115+
return; // TODO: add bailout message
116116
if (strcmp(tok->str().c_str(), op) == 0) {
117117
astFlattenCopy(tok->astOperand1(), op, out, depth);
118118
astFlattenCopy(tok->astOperand2(), op, out, depth);
@@ -140,7 +140,7 @@ nonneg int astCount(const Token* tok, const char* op, int depth)
140140
{
141141
--depth;
142142
if (!tok || depth < 0)
143-
return 0;
143+
return 0; // TODO: add bailout message
144144
if (strcmp(tok->str().c_str(), op) == 0)
145145
return astCount(tok->astOperand1(), op, depth) + astCount(tok->astOperand2(), op, depth);
146146
return 1;
@@ -1129,6 +1129,7 @@ bool exprDependsOnThis(const Token* expr, bool onVar, nonneg int depth)
11291129
return true;
11301130
if (depth >= 1000)
11311131
// Abort recursion to avoid stack overflow
1132+
// TODO: add bailout message
11321133
return true;
11331134
++depth;
11341135

@@ -1273,6 +1274,7 @@ static SmallVector<ReferenceToken> followAllReferencesInternal(const Token* tok,
12731274
if (!tok)
12741275
return {};
12751276
if (depth < 0) {
1277+
// TODO: add bailout message
12761278
SmallVector<ReferenceToken> refs_result;
12771279
refs_result.emplace_back(tok, std::move(errors));
12781280
return refs_result;
@@ -2931,7 +2933,7 @@ static bool isExpressionChangedAt(const F& getExprTok,
29312933
int depth)
29322934
{
29332935
if (depth < 0)
2934-
return true;
2936+
return true; // TODO: add bailout message
29352937
if (!tok)
29362938
return false;
29372939
if (!tok->isMutableExpr())
@@ -2990,7 +2992,7 @@ Token* findVariableChanged(Token *start, const Token *end, int indirect, const n
29902992
if (!precedes(start, end))
29912993
return nullptr;
29922994
if (depth < 0)
2993-
return start;
2995+
return start; // TODO: add bailout message
29942996
auto getExprTok = utils::memoize([&] {
29952997
return findExpression(start, exprid);
29962998
});
@@ -3089,7 +3091,7 @@ static const Token* findExpressionChangedImpl(const Token* expr,
30893091
Find find)
30903092
{
30913093
if (depth < 0)
3092-
return start;
3094+
return start; // TODO: add bailout message
30933095
if (!precedes(start, end))
30943096
return nullptr;
30953097
const Token* result = nullptr;

lib/checkstl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ static const ValueFlow::Value* getInnerLifetime(const Token* tok,
10781078
int depth = 4)
10791079
{
10801080
if (depth < 0)
1081-
return nullptr;
1081+
return nullptr;// TODO: add bailout message
10821082
if (!tok)
10831083
return nullptr;
10841084
for (const ValueFlow::Value& val : tok->values()) {

lib/forwardanalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ namespace {
580580
*/
581581
Progress updateRange(Token* start, const Token* end, int depth = 20) {
582582
if (depth < 0)
583-
return Break(Analyzer::Terminate::Bail);
583+
return Break(Analyzer::Terminate::Bail); // TODO: add bailout message
584584
std::size_t i = 0;
585585
for (Token* tok = start; precedes(tok, end); tok = tok->next()) {
586586
Token* next = nullptr;

lib/programmemory.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ namespace {
13881388

13891389
nonneg int n = astCount(expr, expr->str().c_str());
13901390
if (n > 50)
1391-
return unknown();
1391+
return unknown(); // TODO: add bailout message
13921392
std::vector<const Token*> conditions1 = flattenConditions(expr);
13931393
if (conditions1.empty())
13941394
return unknown();
@@ -1405,7 +1405,7 @@ namespace {
14051405
}
14061406
if (condValues.size() == conditions1.size() && allNegated)
14071407
return negatedValue;
1408-
if (n > 4)
1408+
if (n > 4) // TODO: add bailout message
14091409
return unknown();
14101410
if (!sortConditions(conditions1))
14111411
return unknown();
@@ -1646,6 +1646,7 @@ namespace {
16461646
return execute(tok);
16471647
});
16481648
if (f) {
1649+
// TODO: add bailout message
16491650
if (fdepth >= 0 && !f->isImplicitlyVirtual()) {
16501651
ProgramMemory functionState;
16511652
for (std::size_t i = 0; i < args.size(); ++i) {
@@ -1734,7 +1735,7 @@ namespace {
17341735
depth++;
17351736
}};
17361737
if (depth < 0)
1737-
return unknown();
1738+
return unknown(); // TODO: add bailout message
17381739
ValueFlow::Value v = unknown();
17391740
if (updateValue(v, executeImpl(expr)))
17401741
return v;

lib/valueflow.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ static std::vector<MathLib::bigint> minUnsignedValue(const Token* tok, int depth
10191019
if (!tok)
10201020
return result;
10211021
if (depth < 0)
1022-
return result;
1022+
return result; // TODO: add bailout message
10231023
if (const ValueFlow::Value* v = tok->getKnownValue(ValueFlow::Value::ValueType::INT)) {
10241024
result = {v->intvalue};
10251025
} else if (!Token::Match(tok, "-|%|&|^") && tok->isConstOp() && tok->astOperand1() && tok->astOperand2()) {
@@ -1523,7 +1523,7 @@ static std::vector<ValueFlow::LifetimeToken> getLifetimeTokens(const Token* tok,
15231523
if (pred(tok))
15241524
return {{tok, std::move(errorPath)}};
15251525
if (depth < 0)
1526-
return {{tok, std::move(errorPath)}};
1526+
return {{tok, std::move(errorPath)}}; // TODO: add bailout message
15271527
if (var && var->declarationId() == tok->varId()) {
15281528
if (var->isReference() || var->isRValueReference()) {
15291529
const Token * const varDeclEndToken = var->declEndToken();
@@ -2319,7 +2319,7 @@ struct LifetimeStore {
23192319
static bool hasBorrowingVariables(const std::list<Variable>& vars, const std::vector<const Token*>& args, int depth = 10)
23202320
{
23212321
if (depth < 0)
2322-
return true;
2322+
return true; // TODO: add bailout message
23232323
return std::any_of(vars.cbegin(), vars.cend(), [&](const Variable& var) {
23242324
if (const ValueType* vt = var.valueType()) {
23252325
if (vt->pointer > 0 &&
@@ -3614,7 +3614,7 @@ static void valueFlowSymbolic(const TokenList& tokenlist, const SymbolDatabase&
36143614
static const Token* isStrlenOf(const Token* tok, const Token* expr, int depth = 10)
36153615
{
36163616
if (depth < 0)
3617-
return nullptr;
3617+
return nullptr; // TODO: add bailout message
36183618
if (!tok)
36193619
return nullptr;
36203620
if (!expr)
@@ -6096,6 +6096,7 @@ static bool isContainerSizeChangedByFunction(const Token* tok,
60966096
// Argument not used
60976097
if (!arg->nameToken())
60986098
return false;
6099+
// TODO: add bailout message
60996100
if (depth > 0)
61006101
return isContainerSizeChanged(arg->nameToken(),
61016102
scope->bodyStart,

lib/vf_analyzers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct ValueFlowAnalyzer : Analyzer {
118118
if (!tok)
119119
return {};
120120
if (depth < 0)
121-
return {};
121+
return {}; // TODO: add bailout message
122122
depth--;
123123
if (analyze(tok, Direction::Forward).isRead()) {
124124
ConditionState result;
@@ -826,7 +826,7 @@ static bool bifurcateVariableChanged(const Variable* var,
826826
static bool bifurcate(const Token* tok, const std::set<nonneg int>& varids, const Settings& settings, int depth)
827827
{
828828
if (depth < 0)
829-
return false;
829+
return false; // TODO: add bailout message
830830
if (!tok)
831831
return true;
832832
if (tok->hasKnownIntValue())

0 commit comments

Comments
 (0)