Skip to content

do not depend on lifetime of user object in TokenList #424

Description

@firewave

TokenList depends on a mutable std::vector<std::string> object which holds the files of files which have been tokenized. This seems dangerous as it ties to the lifetime of another object. In some cases this vector is not even necessary to be owned by the user since it is not used outside of the TokenList. It looks the list this could just be owned by TokenList

This supported by the fact that the copy constructors and assignment operators copy the reference which means that two different instances will modify that "global" vector which is obviously wrong and will cause issues.

There was some usage which provides the input file via that vector parameter instead of (or additionally) to the filename parameter. This allows to tokenize multiples explicitly but I am not sure if that is even necessary. This might have contributed to the assumption that it is necessary to provide that vector.

Activity

firewave commented on Oct 12, 2025

@firewave
CollaboratorAuthor

The mess is even bigger as the vector is also referenced and (potentially) modified in Macro and preprocess().

added 11 commits that reference this issue on Oct 12, 2025
added 7 commits that reference this issue on Oct 20, 2025
added 2 commits that reference this issue on Nov 13, 2025

firewave commented on Nov 13, 2025

@firewave
CollaboratorAuthor

https://trac.cppcheck.net/ticket/14268 is an issue in Cppcheck where the object went out of scope.

self-assigned this
on Nov 29, 2025

firewave commented on Nov 29, 2025

@firewave
CollaboratorAuthor

It appears the functionality of providing a list of existing files is required internally by Macro but not downstream in Cppcheck. I cannot really tell if that is actually necessary yet because the code is quite entangled. So far I have failed at a few attempts at doing incremental cleanups but I also do not have a final state to work back from either.

added 2 commits that reference this issue on Nov 30, 2025
added a commit that references this issue on Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions