[PATCH] D147302: [clang][dataflow] Add `create<T>()` methods to `Environment` and `DataflowAnalysisContext`.

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 31 08:44:26 PDT 2023


xazax.hun accepted this revision.
xazax.hun added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:100
+    // used `StorageLocation` subclasses and make them use a `BumpPtrAllocator`.
+    Locs.push_back(std::make_unique<T>(std::forward<Args>(args)...));
+    return *cast<T>(Locs.back().get());
----------------
Would emplace back work? That returns a reference to the just emplaced element saving us the call to `back` making the code a bit more concise.


================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:328
+  template <typename T, typename... Args>
+  std::enable_if_t<std::is_base_of<StorageLocation, T>::value, T &>
+  create(Args &&...args) {
----------------
Just curious, what is the reason for repeating the `enable_if` here in addition to the one in the called function? Do we get better error messages?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147302/new/

https://reviews.llvm.org/D147302



More information about the cfe-commits mailing list