[PATCH] D93628: [clang] NFC: Refactor custom class into a lambda in CompilerInvocation
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 22 05:45:59 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbef9eb84b2fb: [clang] NFC: Refactor custom class into a lambda in CompilerInvocation (authored by jansvoboda11).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93628/new/
https://reviews.llvm.org/D93628
Files:
clang/lib/Frontend/CompilerInvocation.cpp
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -157,33 +157,26 @@
Args.push_back(Spelling);
}
-namespace {
-template <typename T> struct FlagToValueNormalizer {
- T Value;
+template <typename T> static constexpr bool is_uint64_t_convertible() {
+ return !std::is_same<T, uint64_t>::value &&
+ llvm::is_integral_or_enum<T>::value;
+}
- Optional<T> operator()(OptSpecifier Opt, unsigned, const ArgList &Args,
- DiagnosticsEngine &) {
+template <typename T,
+ std::enable_if_t<!is_uint64_t_convertible<T>(), bool> = false>
+static auto makeFlagToValueNormalizer(T Value) {
+ return [Value](OptSpecifier Opt, unsigned, const ArgList &Args,
+ DiagnosticsEngine &) -> Optional<T> {
if (Args.hasArg(Opt))
return Value;
return None;
- }
-};
-} // namespace
-
-template <typename T> static constexpr bool is_int_convertible() {
- return sizeof(T) <= sizeof(uint64_t) &&
- std::is_trivially_constructible<T, uint64_t>::value &&
- std::is_trivially_constructible<uint64_t, T>::value;
-}
-
-template <typename T, std::enable_if_t<is_int_convertible<T>(), bool> = false>
-static FlagToValueNormalizer<uint64_t> makeFlagToValueNormalizer(T Value) {
- return FlagToValueNormalizer<uint64_t>{Value};
+ };
}
-template <typename T, std::enable_if_t<!is_int_convertible<T>(), bool> = false>
-static FlagToValueNormalizer<T> makeFlagToValueNormalizer(T Value) {
- return FlagToValueNormalizer<T>{std::move(Value)};
+template <typename T,
+ std::enable_if_t<is_uint64_t_convertible<T>(), bool> = false>
+static auto makeFlagToValueNormalizer(T Value) {
+ return makeFlagToValueNormalizer(uint64_t(Value));
}
static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93628.313312.patch
Type: text/x-patch
Size: 1945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201222/5c66eca4/attachment.bin>
More information about the cfe-commits
mailing list