diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -157,33 +157,26 @@ Args.push_back(Spelling); } -namespace { -template struct FlagToValueNormalizer { - T Value; +template static constexpr bool is_uint64_t_convertible() { + return !std::is_same::value && + llvm::is_integral_or_enum::value; +} - Optional operator()(OptSpecifier Opt, unsigned, const ArgList &Args, - DiagnosticsEngine &) { +template (), bool> = false> +static auto makeFlagToValueNormalizer(T Value) { + return [Value](OptSpecifier Opt, unsigned, const ArgList &Args, + DiagnosticsEngine &) -> Optional { if (Args.hasArg(Opt)) return Value; return None; - } -}; -} // namespace - -template static constexpr bool is_int_convertible() { - return sizeof(T) <= sizeof(uint64_t) && - std::is_trivially_constructible::value && - std::is_trivially_constructible::value; -} - -template (), bool> = false> -static FlagToValueNormalizer makeFlagToValueNormalizer(T Value) { - return FlagToValueNormalizer{Value}; + }; } -template (), bool> = false> -static FlagToValueNormalizer makeFlagToValueNormalizer(T Value) { - return FlagToValueNormalizer{std::move(Value)}; +template (), bool> = false> +static auto makeFlagToValueNormalizer(T Value) { + return makeFlagToValueNormalizer(uint64_t(Value)); } static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,