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

findtoken.h: make sure code is being matchcompiled #6641

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

firewave
Copy link
Collaborator

No description provided.

@firewave
Copy link
Collaborator Author

-D __GNUC__ --check-level=exhaustive lib/utils.cpp

Clang 18 851,620,331 -> 809,036,639
GCC 14 880,259,918 -> 841,976,696

This should help with https://trac.cppcheck.net/ticket/12271.

Detecting match calls in headers is tracked in https://trac.cppcheck.net/ticket/11541.

This is obviously extremely horrible and needs to be done differently. Because templates are involved I could not come up with something better for now - but because of the sizable impact I published it anyways.

@firewave
Copy link
Collaborator Author

The example from https://trac.cppcheck.net/ticket/10765#comment:4.

Clang 17 8,156,089,970 -> 7,669,984,764

@firewave
Copy link
Collaborator Author

@pfultz2 Care to have a look at this? Thanks!

@firewave
Copy link
Collaborator Author

The example from https://trac.cppcheck.net/ticket/10765#comment:4.

Clang 17 3,753,065,367 -> 3,237,960,965

This makes a lot of difference and we really need to figure out how to get this change in properly.

@@ -92,7 +96,8 @@ bool findTokensSkipDeadCodeImpl(const Library& library,
if (found(tok))
return true;
}
if (Token::Match(tok, "if|for|while (") && Token::simpleMatch(tok->linkAt(1), ") {")) {
//if (Token::Match(tok, "if|for|while (") && Token::simpleMatch(tok->linkAt(1), ") {")) {
if (findTokensSkipDeadCodeImplMatch_1(tok)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why cant the match compiler be updated to automatically generate this? This seems very problematic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems obvious in hindsight. But thinking about it I think there might be problems.

That would cause the matchcompiler.h include to spill which seems undesired. Same with the match functions. The latter will probably cause conflicts in other matchcompiled files which include this.

Can check thought if if it would work if we also process header files. Would be a better approach - albeit I would prefer if it only were temporary.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would cause the matchcompiler.h include to spill which seems undesired

What do you mean spill? There is a header guard.

Same with the match functions. The latter will probably cause conflicts in other matchcompiled files which include this.

I thought each function is appended a unique number.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would cause the matchcompiler.h include to spill which seems undesired

What do you mean spill? There is a header guard.

I mean that it will be includes in all files including this even when not necessary. It is just not clean.

Same with the match functions. The latter will probably cause conflicts in other matchcompiled files which include this.

I thought each function is appended a unique number.

I am not sure if that is unique globally or locally. The first is unnecessary since we only generate functions within source files. But will immediately come up if I try to include the headers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay. I just remembered the main issue.

The files need to be matchcompiled thus you need to store the modified files and build those. But if you do that with headers you also need to inject an additional header path in release builds and you two headers of the same name which might also cause issues.

So it is not just include the *.h in the matchcompiler.

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