[PATCH] D84668: [clang][cli] Port TargetOpts simple string based options to new option parsing system
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 16 04:04:00 PST 2020
jansvoboda11 added inline comments.
================
Comment at: clang/lib/Frontend/CompilerInvocation.cpp:248
+template <typename T,
+ std::enable_if_t<std::is_same<T, unsigned>::value, bool> = true>
static void denormalizeSimpleEnum(SmallVectorImpl<const char *> &Args,
----------------
dexonsmith wrote:
> I don't think this needs to be templated; it can just use the same prototype it did before this patch (using `unsigned` directly).
I can remove it. I originally put it in there to be symmetrical with the template below.
================
Comment at: clang/lib/Frontend/CompilerInvocation.cpp:264-265
+template <typename T,
+ std::enable_if_t<!std::is_same<T, unsigned>::value, bool> = true>
+static void denormalizeSimpleEnum(SmallVectorImpl<const char *> &Args,
----------------
dexonsmith wrote:
> Once the template is gone from the `unsigned` overload above, I wonder if we can use `!std::is_convertible<T, unsigned>` here, and let the `unsigned` overload directly catch any enums that aren't strongly typed.
Unfortunately, `std::is_convertible<T, unsigned>::value == false` when `T` is an `enum class` (and it's the same for `std::is_constructible<unsigned, T>::value`): <https://godbolt.org/z/Pvsr7v>.
I didn't find any type trait in the standard library that would have the same semantics as `static_cast<unsigned, T>`, but we could use something like this: <https://godbolt.org/z/738dhe>.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84668/new/
https://reviews.llvm.org/D84668
More information about the cfe-commits
mailing list