Skip to content

Commit

Permalink
Usa an actual depth
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 committed Nov 25, 2023
1 parent a0ff7d8 commit 815d013
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 0 additions & 8 deletions lib/forwardanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@
#include <vector>

namespace {
struct OnExit {
std::function<void()> f;

~OnExit() {
f();
}
};

struct ForwardTraversal {
enum class Progress { Continue, Break, Skip };
enum class Terminate { None, Bail, Inconclusive };
Expand Down
3 changes: 2 additions & 1 deletion lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ namespace {
const Settings* settings = nullptr;
int fdepth = 4;
ValueFlow::Value unknown = ValueFlow::Value::unknown();
int depth = 100;
int depth = 10;

explicit Executor(ProgramMemory* pm = nullptr, const Settings* settings = nullptr) : pm(pm), settings(settings) {}

Expand Down Expand Up @@ -1614,6 +1614,7 @@ namespace {
ValueFlow::Value execute(const Token* expr)
{
depth--;
OnExit onExit{[&] { depth++; }};
if (depth < 0)
return unknown;
ValueFlow::Value v = executeImpl(expr);
Expand Down
8 changes: 8 additions & 0 deletions lib/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ struct SelectMapValues {
}
};

struct OnExit {
std::function<void()> f;

~OnExit() {
f();
}
};

template<class Range, class T>
bool contains(const Range& r, const T& x)
{
Expand Down

0 comments on commit 815d013

Please sign in to comment.