[PATCH] D18876: NFC: unify clang / LLVM atomic ordering

JF Bastien via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 15 13:07:32 PDT 2016


jfb added a comment.

In http://reviews.llvm.org/D18876#399934, @jyknight wrote:

> The large amount of casting to/from integers for AtomicOrderingCABI makes me think that it probably ought not actually be converted to an enum class after all.


Untrusted user input with enums is a problem: you have to range-check before casting the int to the enum, with or without enum class, otherwise out-of-range is UB. I like it being explicit, but yeah what I had was wordy so I factored out the check.

Casting *out* of the enum to generate constants is also wordy, but I think that's also fine. We could add a version of `ConstantInt` which takes in `is_integral_or_enum` but that seems like a lot of work for little typing? I'm happy to do that if you think it's worthwhile.


http://reviews.llvm.org/D18876





More information about the cfe-commits mailing list