danmar/cppcheck — pull request #386 by Dmitry-Me (2014-08-05 13:37:42+00:00)
Title: Must limit AST parent search to some reasonable depth.

Current implementation takes hours (maybe days) on long initializer lists such as this:

const char whatever[size] = { 1, 2, 1, 2 ...} //the list should be something like 600 thousand elements long.

The problem is that the loop which searches for the AST parent starts with the first comma and then traverses all the commas in the list. Then it moves to the second comma and again traverses all commas on the right of that second comma. On a long enough list this takes ages. One solution is to limit the search depth.