bloomberg/clangmetatool

`IncludeGraph::getData()` should return const pointer

liangti opened this issue · 0 comments

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.