[PATCH] D107378: Make enum iteration with seq safe by default

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 2 09:28:46 PDT 2021


kuhar added inline comments.


================
Comment at: llvm/include/llvm/ADT/Sequence.h:105-106
+};
+constexpr force_iteration_on_noniterable_enum_t
+    force_iteration_on_noniterable_enum;
+
----------------
aaron.ballman wrote:
> kuhar wrote:
> > aaron.ballman wrote:
> > > I'm pretty sure this is an ODR violation without also declaring it as `inline` (this definition otherwise has internal linkage).
> > What's the proper way to do it in the pre-C++17 world? I saw that both `llvm::None` and `std::piecewise_construct` do it the same way.
> You need to use a function to wrap the variables, or you ignore the ODR issue and hope nothing explodes later. Good point on C++17 though, we don't currently support it. So I think this is "fine" for the moment and we can come back and fix it later once we bump to C++17.
Since this pattern has been working for years with the existing code (`llvm::None`, `std::piecewise_construct`), I added a TODO to revisit this after we update to c++17 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107378



More information about the llvm-commits mailing list