Skip to content
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
4 changes: 4 additions & 0 deletions lib/forwardanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,12 @@ struct ForwardTraversal {
Progress updateRange(Token* start, const Token* end, int depth = 20) {
if (depth < 0)
return Break(Terminate::Bail);
std::size_t i = 0;
for (Token* tok = start; tok && tok != end; tok = tok->next()) {
Token* next = nullptr;
if (tok->index() <= i)
throw InternalError(tok, "Cyclic forward analysis.");
i = tok->index();

if (tok->link()) {
// Skip casts..
Expand Down
5 changes: 5 additions & 0 deletions lib/reverseanalyzer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "reverseanalyzer.h"
#include "analyzer.h"
#include "astutils.h"
#include "errortypes.h"
#include "forwardanalyzer.h"
#include "settings.h"
#include "symboldatabase.h"
Expand Down Expand Up @@ -119,7 +120,11 @@ struct ReverseTraversal {
void traverse(Token* start, const Token* end = nullptr) {
if (start == end)
return;
std::size_t i = start->index();
for (Token* tok = start->previous(); tok != end; tok = tok->previous()) {
if (tok->index() >= i)
throw InternalError(tok, "Cyclic reverse analysis.");
i = tok->index();
if (tok == start || (tok->str() == "{" && (tok->scope()->type == Scope::ScopeType::eFunction ||
tok->scope()->type == Scope::ScopeType::eLambda))) {
break;
Expand Down
2 changes: 2 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5281,6 +5281,8 @@ bool Tokenizer::simplifyTokenList2()

Token::assignProgressValues(list.front());

list.front()->assignIndexes();

list.createAst();
// needed for #7208 (garbage code) and #7724 (ast max depth limit)
list.validateAst();
Expand Down