Skip to content

moved TokenList reference out of TokenFrontBack / some cleanups#7454

Merged
chrchr-github merged 3 commits intocppcheck-opensource:mainfrom
firewave:backforthlist
Apr 14, 2025
Merged

moved TokenList reference out of TokenFrontBack / some cleanups#7454
chrchr-github merged 3 commits intocppcheck-opensource:mainfrom
firewave:backforthlist

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

No description provided.

@firewave
Copy link
Copy Markdown
Collaborator Author

This is in preparation because an upcoming PR will change the lifetime of TokenList which requires me to move it.

Please let's not get into a "you should not have references in objects" discussion. That will be addressed later (I thought our usage was fine but there was a fundamental misunderstanding on my side) - with the help of clang-tidy.

@pfultz2
Copy link
Copy Markdown
Contributor

pfultz2 commented Apr 12, 2025

If a token has a reference back to the list then maybe it should be a weak_ptr or shared_ptr so we have better tracking of lifetimes.

Also it seems like the TokenList should construct the Token class instead since the lifetime is tied together. Although, I dont really follow what this code does, it seems quite confusing with a lot of pointer chasing going on.

Comment thread lib/token.h
@firewave
Copy link
Copy Markdown
Collaborator Author

If a token has a reference back to the list then maybe it should be a weak_ptr or shared_ptr so we have better tracking of lifetimes.

Yes - I will look into this when I review the usage of references in class.

Also it seems like the TokenList should construct the Token class instead since the lifetime is tied together. Although, I dont really follow what this code does, it seems quite confusing with a lot of pointer chasing going on.

One of the reasons why I wanted things more explicit and less cyclic/dependent.

@chrchr-github chrchr-github merged commit 1cd7299 into cppcheck-opensource:main Apr 14, 2025
53 checks passed
@firewave firewave deleted the backforthlist branch April 14, 2025 08:37
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.

4 participants