From: Richard Smith Date: Thu, 13 Apr 2017 00:14:39 +0000 (+0000) Subject: Work around MSVC rejects-valid bug related to C++11 narrowing conversions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc359e4a20c7224e16c3e5580883f94bbc998c68;p=llvm Work around MSVC rejects-valid bug related to C++11 narrowing conversions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300144 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Option/ArgList.h b/include/llvm/Option/ArgList.h index 91baf4c8ac4..4ed28d7a852 100644 --- a/include/llvm/Option/ArgList.h +++ b/include/llvm/Option/ArgList.h @@ -162,6 +162,10 @@ protected: // Protect the dtor to ensure this type is never destroyed polymorphically. ~ArgList() = default; + // Implicitly convert a value to an OptSpecifier. Used to work around a bug + // in MSVC's implementation of narrowing conversion checking. + static OptSpecifier toOptSpecifier(OptSpecifier S) { return S; } + public: /// @name Arg Access /// @{ @@ -192,21 +196,23 @@ public: template iterator_range> filtered(OptSpecifiers ...Ids) const { - OptRange Range = getRange({Ids...}); + OptRange Range = getRange({toOptSpecifier(Ids)...}); auto B = Args.begin() + Range.first; auto E = Args.begin() + Range.second; using Iterator = filtered_iterator; - return make_range(Iterator(B, E, {Ids...}), Iterator(E, E, {Ids...})); + return make_range(Iterator(B, E, {toOptSpecifier(Ids)...}), + Iterator(E, E, {toOptSpecifier(Ids)...})); } template iterator_range> filtered_reverse(OptSpecifiers ...Ids) const { - OptRange Range = getRange({Ids...}); + OptRange Range = getRange({toOptSpecifier(Ids)...}); auto B = Args.rend() - Range.second; auto E = Args.rend() - Range.first; using Iterator = filtered_reverse_iterator; - return make_range(Iterator(B, E, {Ids...}), Iterator(E, E, {Ids...})); + return make_range(Iterator(B, E, {toOptSpecifier(Ids)...}), + Iterator(E, E, {toOptSpecifier(Ids)...})); } /// @}