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

IncludeGraph::getData() should return const pointer #70

Open
liangti opened this issue Apr 7, 2022 · 0 comments
Open

IncludeGraph::getData() should return const pointer #70

liangti opened this issue Apr 7, 2022 · 0 comments

Comments

@liangti
Copy link
Contributor

liangti commented Apr 7, 2022

Is your feature request related to a problem? Please describe.

Currently clients can fully access IncludeGraphData by IncludeGraph::getData() since it is returning a raw pointer.

It is volatile and then becomes stateful, so that may be easily misused.

Describe the solution you'd like

We should instead make IncludeGraph::getData() return const pointer.

So that IncludeGraphData can only be changed in frontend action and ppcallback, and becomes read-only toward clients.

The component that needs to modify IncludeGraphData should make a copy of it and take care of the lifetime of the copy themselves

Describe alternatives you've considered

Additional context

We should consider making all getData() return const pointer like this: https://github.com/bloomberg/clangmetatool/blob/master/include/clangmetatool/collectors/find_functions.h#L63

Because clang frontend action and ppcallback does not rely on those getData() to access data structures. Those data structures are passed by reference into callbacks

So getData() mostly are accessed by clients. And those data structures should be determined and unchanged once frontend compilation finished.

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