[PATCH] D65382: [analyzer][NFC] Refactoring BugReporter.cpp P4.: If it can be const, make it const

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 31 08:00:42 PDT 2019

NoQ added a comment.

In D65382#1605769 <https://reviews.llvm.org/D65382#1605769>, @baloghadamsoftware wrote:

> Most managers are stateful because they also store the elements they manage (e.g. `ProgramStateManager` stores states, `SValBuilder` owns other managers such as `SymbolManager` that stores symbols etc.)

That's an implementation detail, a memoization, a good use case for `mutable` if we go for const-correctness. For example, no observable properties of `SymbolManager` change when it allocates a new symbol. The interface only allows you to ask "What's the symbol for a //value-that-transcends-time// with a certain identity?" and it retrieves you that symbol. There's no way to find out if the symbol is freshly created or already cached, and there shouldn't be a way to find this out, because this is entirely immaterial and meaningless.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list