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

refs #13698 - Library: avoid impossible type lookups #7373

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

firewave
Copy link
Collaborator

No description provided.

@firewave firewave changed the title refs #13698 - Library: avoid some lookups of empty strings refs #13698 - Library: avoid impossible type lookups Mar 13, 2025
@firewave firewave marked this pull request as draft March 13, 2025 08:49
@firewave
Copy link
Collaborator Author

Okay - this appears to be quite a mess (surprise, surprise).

The function declaration stuff has lots of other cases. And I am also seeing function calls getting through which do not seem to be recognized as such.

@firewave firewave force-pushed the lib-lookup branch 2 times, most recently from aa7134f to c212dfc Compare March 13, 2025 09:09
@firewave
Copy link
Collaborator Author

And I am also seeing function calls getting through which do not seem to be recognized as such.

I wonder if that is a chicken/egg issue. In the --dump output it is associated with a function but in the lookup it isn't. I guess because that relation has not yet been established at that point.

Maybe those type lookups need to be deferred?

@firewave

This comment was marked as resolved.

Comment on lines +1917 to 1919
// TODO: this is flawed and might result in lookups like "uint64_tflags_"
std::string typestr = withoutStd ? "std::" : "";
while (Token::Match(tok, "%name%|::")) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrchr-github could you please have a look at this? Thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off the top of my head, you could try something like this

if (tok->str() == "::")
    tok = tok->next();
while (Token::Match(tok, "%name% ::")) {
    typestr += tok->str();
    typestr += "::";
    tok = tok->tokAt(2);
}
if (tok && tok->isName()) {
    typestr += tok->str();
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That's probably as convoluted as what I would have come up with (if I had tried). I was hoping there might be something more straight forward I was missing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That produces proper types to look up. Published in #7378.

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

Successfully merging this pull request may close these issues.

2 participants