[clang] [NFC] [analyzer] Factor out SymbolManager::get<*> (PR #121781)

Arseniy Zaostrovnykh via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 7 00:07:22 PST 2025


================
@@ -525,14 +527,14 @@ class SymbolManager {
 
   static bool canSymbolicate(QualType T);
 
-  /// Make a unique symbol for MemRegion R according to its kind.
-  const SymbolRegionValue* getRegionValueSymbol(const TypedValueRegion* R);
+  template <typename T, typename... Args> const T *get(Args &&...args);
----------------
necto wrote:

> If somebody reads this generic declaration without any context, they won't see any connection to symbols. Perhaps it would be good to either rename `T` to something like `SymbolType` or add a brief comment to describe the role of this method.

That makes sense. I'll do both once we agree on the next point

> 🤔 In fact, now that I write this, maybe it would be better to rename this method to "`make`" or something similar to highlight that it's a factory method that makes new symbol objects (as opposed to e.g. `ProgramState::get<>()` which queries an existing state trait object from the state).

I was considering "make" briefly, but it is not entirely correct: this function doesn't always make a `SymExpr`, sometimes it retrieves an existing one matching the arguments. Besides, most of the replaced member functions were called `get*`. How do you like `findOrCreate`, `createIfNone`, `ensureExists`, `obtain`, `acquire`, `procure`?

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


More information about the cfe-commits mailing list