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

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 2 08:28:41 PDT 2021


aaron.ballman 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;
+
----------------
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.


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