From 431a9c00a56cf4c603be1cf5f773b193621d8150 Mon Sep 17 00:00:00 2001 From: Kai Blaschke Date: Mon, 19 Feb 2024 16:55:19 +0100 Subject: Fixed a huge amount of Clang warnings On Linux and macOS, using Clang to compile OpenStarbound produces about 400 MB worth of warnings during the build, making the compiler output unreadable and slowing the build down considerably. 99% of the warnings were unqualified uses of std::move and std::forward, which are now all properly qualified. Fixed a few other minor warnings about non-virtual destructors and some uses of std::move preventing copy elision on temporary objects. Most remaining warnings are now unused parameters. --- source/core/StarAlgorithm.hpp | 68 +++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'source/core/StarAlgorithm.hpp') diff --git a/source/core/StarAlgorithm.hpp b/source/core/StarAlgorithm.hpp index e26917a..ef82cc8 100644 --- a/source/core/StarAlgorithm.hpp +++ b/source/core/StarAlgorithm.hpp @@ -14,7 +14,7 @@ template struct construct { template ToType operator()(FromTypes&&... fromTypes) const { - return ToType(forward(fromTypes)...); + return ToType(std::forward(fromTypes)...); } }; @@ -29,7 +29,7 @@ template struct SwallowReturn { template void operator()(T&&... args) { - func(forward(args)...); + func(std::forward(args)...); } Func func; @@ -37,7 +37,7 @@ struct SwallowReturn { template SwallowReturn swallow(Func f) { - return SwallowReturn{move(f)}; + return SwallowReturn{std::move(f)}; } struct Empty { @@ -58,18 +58,18 @@ struct FunctionComposer { template decltype(auto) operator()(T&&... args) { - return f1(f2(forward(args)...)); + return f1(f2(std::forward(args)...)); } }; template decltype(auto) compose(FirstFunction&& firstFunction, SecondFunction&& secondFunction) { - return FunctionComposer{move(forward(firstFunction)), move(forward(secondFunction))}; + return FunctionComposer{std::move(std::forward(firstFunction)), std::move(std::forward(secondFunction))}; } template decltype(auto) compose(FirstFunction firstFunction, SecondFunction secondFunction, ThirdFunction thirdFunction, RestFunctions... restFunctions) { - return compose(forward(firstFunction), compose(forward(secondFunction), compose(forward(thirdFunction), forward(restFunctions)...))); + return compose(std::forward(firstFunction), compose(std::forward(secondFunction), compose(std::forward(thirdFunction), std::forward(restFunctions)...))); } template @@ -260,7 +260,7 @@ void sortByComputedValue(Container& container, Getter&& valueGetter, bool stable template void stableSortByComputedValue(Container& container, Getter&& valueGetter) { - return sortByComputedValue(container, forward(valueGetter), true); + return sortByComputedValue(container, std::forward(valueGetter), true); } template @@ -293,7 +293,7 @@ template void transformInto(OutContainer& outContainer, InContainer&& inContainer, Function&& function) { for (auto&& elem : inContainer) { if (std::is_rvalue_reference::value) - outContainer.insert(outContainer.end(), function(move(elem))); + outContainer.insert(outContainer.end(), function(std::move(elem))); else outContainer.insert(outContainer.end(), function(elem)); } @@ -302,7 +302,7 @@ void transformInto(OutContainer& outContainer, InContainer&& inContainer, Functi template OutContainer transform(InContainer&& container, Function&& function) { OutContainer res; - transformInto(res, forward(container), forward(function)); + transformInto(res, std::forward(container), std::forward(function)); return res; } @@ -326,7 +326,7 @@ OutputContainer zipWith(Function&& function, Container1 const& cont1, Container2 // default constructed state. template T take(T& t) { - T t2 = move(t); + T t2 = std::move(t); t = T(); return t2; } @@ -356,7 +356,7 @@ public: template OutputProxy& operator=(T&& value) { - m_function(forward(value)); + m_function(std::forward(value)); return *this; } @@ -365,7 +365,7 @@ public: }; explicit FunctionOutputIterator(UnaryFunction f = UnaryFunction()) - : m_function(move(f)) {} + : m_function(std::move(f)) {} OutputProxy operator*() { return OutputProxy(m_function); @@ -385,7 +385,7 @@ private: template FunctionOutputIterator makeFunctionOutputIterator(UnaryFunction f) { - return FunctionOutputIterator(move(f)); + return FunctionOutputIterator(std::move(f)); } // Wraps a nullary function to produce an input iterator @@ -401,7 +401,7 @@ public: typedef typename std::result_of::type FunctionReturnType; explicit FunctionInputIterator(NullaryFunction f = {}) - : m_function(move(f)) {} + : m_function(std::move(f)) {} FunctionReturnType operator*() { return m_function(); @@ -421,7 +421,7 @@ private: template FunctionInputIterator makeFunctionInputIterator(NullaryFunction f) { - return FunctionInputIterator(move(f)); + return FunctionInputIterator(std::move(f)); } template @@ -449,14 +449,14 @@ ReverseWrapper reverseIterate(Iterable& list) { template class FinallyGuard { public: - FinallyGuard(Functor functor) : functor(move(functor)), dismiss(false) {} + FinallyGuard(Functor functor) : functor(std::move(functor)), dismiss(false) {} - FinallyGuard(FinallyGuard&& o) : functor(move(o.functor)), dismiss(o.dismiss) { + FinallyGuard(FinallyGuard&& o) : functor(std::move(o.functor)), dismiss(o.dismiss) { o.cancel(); } FinallyGuard& operator=(FinallyGuard&& o) { - functor = move(o.functor); + functor = std::move(o.functor); dismiss = o.dismiss; o.cancel(); return *this; @@ -478,7 +478,7 @@ private: template FinallyGuard::type> finally(Functor&& f) { - return FinallyGuard(forward(f)); + return FinallyGuard(std::forward(f)); } // Generates compile time sequences of indexes from MinIndex to MaxIndex @@ -498,12 +498,12 @@ struct GenIndexSequence { template decltype(auto) tupleUnpackFunctionIndexes(Function&& function, Tuple&& args, IndexSequence const&) { - return function(get(forward(args))...); + return function(get(std::forward(args))...); } template decltype(auto) tupleUnpackFunction(Function&& function, Tuple&& args) { - return tupleUnpackFunctionIndexes(forward(function), forward(args), + return tupleUnpackFunctionIndexes(std::forward(function), std::forward(args), typename GenIndexSequence<0, std::tuple_size::type>::value>::type()); } @@ -512,12 +512,12 @@ decltype(auto) tupleUnpackFunction(Function&& function, Tuple&& args) { template decltype(auto) tupleApplyFunctionIndexes(Function&& function, Tuple&& args, IndexSequence const&) { - return make_tuple(function(get(forward(args)))...); + return make_tuple(function(get(std::forward(args)))...); } template decltype(auto) tupleApplyFunction(Function&& function, Tuple&& args) { - return tupleApplyFunctionIndexes(forward(function), forward(args), + return tupleApplyFunctionIndexes(std::forward(function), std::forward(args), typename GenIndexSequence<0, std::tuple_size::type>::value>::type()); } @@ -530,35 +530,35 @@ void tupleCallFunctionCaller(Function&&, Tuple&&) {} template void tupleCallFunctionCaller(Tuple&& t, Function&& function) { - tupleCallFunctionCaller(forward(t), forward(function)); - function(get(forward(t))); + tupleCallFunctionCaller(std::forward(t), std::forward(function)); + function(get(std::forward(t))); } template void tupleCallFunctionExpander(Tuple&& t, Function&& function, tuple const&) { - tupleCallFunctionCaller(forward(t), forward(function)); + tupleCallFunctionCaller(std::forward(t), std::forward(function)); } template void tupleCallFunction(Tuple&& t, Function&& function) { - tupleCallFunctionExpander(forward(t), forward(function), forward(t)); + tupleCallFunctionExpander(std::forward(t), std::forward(function), std::forward(t)); } // Get a subset of a tuple template decltype(auto) subTupleIndexes(Tuple&& t, IndexSequence const&) { - return make_tuple(get(forward(t))...); + return make_tuple(get(std::forward(t))...); } template decltype(auto) subTuple(Tuple&& t) { - return subTupleIndexes(forward(t), GenIndexSequence::type()); + return subTupleIndexes(std::forward(t), GenIndexSequence::type()); } template decltype(auto) trimTuple(Tuple&& t) { - return subTupleIndexes(forward(t), typename GenIndexSequence::type>::value>::type()); + return subTupleIndexes(std::forward(t), typename GenIndexSequence::type>::value>::type()); } // Unpack a parameter expansion into a container @@ -568,14 +568,14 @@ void unpackVariadicImpl(Container&) {} template void unpackVariadicImpl(Container& container, TFirst&& tfirst, TRest&&... trest) { - container.insert(container.end(), forward(tfirst)); - unpackVariadicImpl(container, forward(trest)...); + container.insert(container.end(), std::forward(tfirst)); + unpackVariadicImpl(container, std::forward(trest)...); } template Container unpackVariadic(T&&... t) { Container c; - unpackVariadicImpl(c, forward(t)...); + unpackVariadicImpl(c, std::forward(t)...); return c; } @@ -587,7 +587,7 @@ void callFunctionVariadic(Function&&) {} template void callFunctionVariadic(Function&& function, Arg1&& arg1, ArgRest&&... argRest) { function(arg1); - callFunctionVariadic(forward(function), forward(argRest)...); + callFunctionVariadic(std::forward(function), std::forward(argRest)...); } template -- cgit v1.2.3