[clang] [nfc][analyzer] Add MemSpace trait to program state (PR #123003)

Michael Flanders via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 23 18:44:21 PST 2025


Flandini wrote:

> Have you considered changing `MemRegion::getMemorySpace()` into `MemRegion::getMemorySpace(ProgramStateRef)`?

I thought about this, but I decided against it since I am thinking that MemSpaces will eventually be their own separate thing, not part of the MemRegion hierarchy, i.e., MemSpaces will eventually just be a trait thing, maybe with its own checker depending on how much functionality can be added with this different implementation?

All this being said, I am happy to change the API of how we get memory spaces, I am not tied to the current approach/API, just that we can move towards better results for https://github.com/llvm/llvm-project/issues/115410.

> (Maybe in some contexts where we currently call `getMemorySpace` we just don't have a State, and can't easily get one - and that would kill this approach.) 

This has been the main thing I'm working through on this PR. This PR doesn't totally remove all `getMemorySpace` calls; this PR covers most of the files that use memory spaces, but there still remain some spots that are harder for me to change right now that I plan to work through. These are in RegionStore and ClusterAnalysis which don't take state, MemRegion (including the changes that would happen after removing MemSpace from the hierarchy) and all the print/dump methods which don't take state, and a dozen spots in StackAddrEscapeChecker that don't take state that I couldn't think of an immediate way to add state.

This is also related to @Xazax-hun's above question about whether it would be possible to make all the changes here at once, do you have thoughts on that @steakhal, I think you tried some stuff here?



https://github.com/llvm/llvm-project/pull/123003


More information about the cfe-commits mailing list