Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language Server should notice loop nesting #20

Open
vbar opened this issue Nov 18, 2022 · 0 comments
Open

Language Server should notice loop nesting #20

vbar opened this issue Nov 18, 2022 · 0 comments

Comments

@vbar
Copy link
Collaborator

vbar commented Nov 18, 2022

Current hooks-guard-in-for clang-tidy check only looks at for loops in isolation. It should also take into account their nesting, so that when it proposes to insert a call to _g, it computes its second argument not just as this loop iterations + 1, but as (this loop iterations + 1) * (each parent loop's iteration's), e.g.

uint8_t acc[20];

for (int i = 0; _g(__LINE__, 11), i < 10; ++i)
{
    for (int j = 0; _g(__LINE__, 30), j < 2; ++j)
    {
        for (int k = 0; _g(__LINE__, 120),  k < 5; ++k)
        {
            hook_account(acc, 20);
        }
        for (int k = 0; _g(__LINE__, 120),  k < 5; ++k)
        {
            hook_account(acc, 20);
        }
    }
}

while also recognizing when the computation cannot be done (e.g. when the loops have dynamic limits).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant