[lldb] [llvm] [mlir] [Support] Remove virtual functions from formatv (PR #207516)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 04:41:22 PDT 2026
mstorsjo wrote:
This change causes a bunch of very loud/verbose warnings when building LLVM with GCC (at least with GCC 9, in Ubuntu 20.04).
Building with GCC isn't anywhere near free of warnings anyway, but this produces warnings even when building as small things as `llvm-tblgen`. If cross compiling LLVM, it builds the `llvm-min-tblgen`, `llvm-tblgen` and `*-tblgen` binaries as native binaries with the system default compiler - so this makes these loud warnings appear even in that case, even if doing the main cross build with Clang.
The warnings look like this:
```
[209/214] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/BalancedPartitioning.cpp.o
In file included from /home/martin/code/llvm-project/llvm/include/llvm/Support/FormatCommon.h:13,
from /home/martin/code/llvm-project/llvm/include/llvm/Support/FormatVariadic.h:34,
from /home/martin/code/llvm-project/llvm/lib/Support/BalancedPartitioning.cpp:18:
/home/martin/code/llvm-project/llvm/include/llvm/Support/FormatVariadicDetails.h: In instantiation of ‘void llvm::support::detail::FormatFunctor<T>::operator()(llvm::raw_ostream&, llvm::StringRef) [with T = const std::optional<unsigned int>&]’:
/home/martin/code/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:52: required from ‘static Ret llvm::function_ref<Ret(Params ...)>::callback_fn(intptr_t, Params ...) [with Callable = llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&>; Ret = void; Params = {llvm::raw_ostream&, llvm::StringRef}; intptr_t = long int]’
/home/martin/code/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:66:55: required from ‘llvm::function_ref<Ret(Params ...)>::function_ref(Callable&&, std::enable_if_t<(! std::is_same<typename llvm::remove_cvref<Callable>::type, llvm::function_ref<Ret(Params ...)> >::value)>*, std::enable_if_t<(std::is_void<_Tp>::value || std::is_convertible<decltype (declval<Callable>()((declval<Params>)()...)), Ret>::value)>*) [with Callable = llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&>&; Ret = void; Params = {llvm::raw_ostream&, llvm::StringRef}; std::enable_if_t<(! std::is_same<typename llvm::remove_cvref<Callable>::type, llvm::function_ref<Ret(Params ...)> >::value)> = void; std::enable_if_t<(std::is_void<_Tp>::value || std::is_convertible<decltype (declval<Callable>()((declval<Params>)()...)), Ret>::value)> = void]’
/home/martin/code/llvm-project/llvm/include/llvm/Support/FormatVariadic.h:137:25: required from ‘std::array<llvm::function_ref<void(llvm::raw_ostream&, llvm::StringRef)>, std::tuple_size<_Tp>::value> llvm::formatv_object<Tuple>::create_adapters::operator()(Ts& ...) [with Ts = {llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&>}; Tuple = std::tuple<llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&> >]’
/usr/include/c++/9/bits/invoke.h:60:36: required from ‘constexpr _Res std::__invoke_impl(std::__invoke_other, _Fn&&, _Args&& ...) [with _Res = std::array<llvm::function_ref<void(llvm::raw_ostream&, llvm::StringRef)>, 3>; _Fn = llvm::formatv_object<std::tuple<llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&> > >::create_adapters; _Args = {llvm::support::detail::FormatFunctor<const long unsigned int&>&, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >&, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&>&}]’
/usr/include/c++/9/bits/invoke.h:95:40: required from ‘constexpr typename std::__invoke_result<_Functor, _ArgTypes>::type std::__invoke(_Callable&&, _Args&& ...) [with _Callable = llvm::formatv_object<std::tuple<llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&> > >::create_adapters; _Args = {llvm::support::detail::FormatFunctor<const long unsigned int&>&, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >&, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&>&}; typename std::__invoke_result<_Functor, _ArgTypes>::type = std::array<llvm::function_ref<void(llvm::raw_ostream&, llvm::StringRef)>, 3>]’
/usr/include/c++/9/tuple:1684:27: required from ‘constexpr decltype(auto) std::__apply_impl(_Fn&&, _Tuple&&, std::index_sequence<_Idx ...>) [with _Fn = llvm::formatv_object<std::tuple<llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&> > >::create_adapters; _Tuple = std::tuple<llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&> >&; long unsigned int ..._Idx = {0, 1, 2}; std::index_sequence<_Idx ...> = std::integer_sequence<long unsigned int, 0, 1, 2>]’
/usr/include/c++/9/tuple:1694:31: required from ‘constexpr decltype(auto) std::apply(_Fn&&, _Tuple&&) [with _Fn = llvm::formatv_object<std::tuple<llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&> > >::create_adapters; _Tuple = std::tuple<llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&> >&]’
/home/martin/code/llvm-project/llvm/include/llvm/Support/FormatVariadic.h:145:35: required from ‘llvm::formatv_object<Tuple>::formatv_object(llvm::StringRef, Tuple&&, bool) [with Tuple = std::tuple<llvm::support::detail::FormatFunctor<const long unsigned int&>, llvm::support::detail::FormatFunctor<llvm::iterator_range<const unsigned int*> >, llvm::support::detail::FormatFunctor<const std::optional<unsigned int>&> >]’
/home/martin/code/llvm-project/llvm/include/llvm/Support/FormatVariadic.h:250:10: required from ‘auto llvm::formatv(bool, const char*, Ts&& ...) [with Ts = {const long unsigned int&, llvm::iterator_range<const unsigned int*>, const std::optional<unsigned int>&}]’
/home/martin/code/llvm-project/llvm/include/llvm/Support/FormatVariadic.h:255:24: required from ‘auto llvm::formatv(const char*, Ts&& ...) [with Ts = {const long unsigned int&, llvm::iterator_range<const unsigned int*>, const std::optional<unsigned int>&}]’
/home/martin/code/llvm-project/llvm/lib/Support/BalancedPartitioning.cpp:26:77: required from here
/home/martin/code/llvm-project/llvm/include/llvm/Support/FormatVariadicDetails.h:66:51: warning: parameter ‘Options’ set but not used [-Wunused-but-set-parameter]
66 | void operator()(llvm::raw_ostream &S, StringRef Options) {
| ~~~~~~~~~~^~~~~~~
cc1plus: warning: unrecognized command line option ‘-Wno-c99-extensions’
```
(With this warning repeated 4 times.)
https://github.com/llvm/llvm-project/pull/207516
More information about the llvm-commits
mailing list