Everywhere: Fix -Wunused-template warnings emited by recent Clang

The latest version of Clang got better at detecting unused templates. It
detected one truly unused template in our codebase. The rest are either
from templated functions that are not always used (depending on the
compile-time configuration) or from templated functions that are
incorrectly annotated with static.
This commit is contained in:
Lucas Chollet committed 2026-08-22 21:48:49 +02:00
1 parent e6b653caa6
commit f4bde6ab14
16 files changed
+37 -58

No files matched your search

+1 -1
View File
@@ -101,7 +101,7 @@ size_t median_of_medians(Collection& collection, size_t left, size_t right, Less
// This is the Lomuto Partition scheme which is simpler but less efficient than Hoare's partitioning scheme that is traditionally used with quicksort
// https://en.wikipedia.org/wiki/Quicksort#Lomuto_partition_scheme
template<typename Collection, typename PivotFn, typename LessThan>
static size_t partition(Collection& collection, size_t left, size_t right, PivotFn pivot_fn, LessThan less_than)
size_t partition(Collection& collection, size_t left, size_t right, PivotFn pivot_fn, LessThan less_than)
{
auto pivot_index = pivot_fn(collection, left, right, less_than);
auto pivot_value = collection.at(pivot_index);
@@ -101,6 +101,7 @@ UNMAP_AFTER_INIT SysFSSMBIOSDirectory::SysFSSMBIOSDirectory(SysFSFirmwareDirecto
initialize_smbios_exposer();
}
#if ARCH(X86_64)
template<typename EntryPoint>
static bool is_entry_point_valid(ReadonlyBytes entry_point)
{
@@ -117,6 +118,7 @@ static bool is_entry_point_valid(ReadonlyBytes entry_point)
return checksum == 0;
}
#endif
UNMAP_AFTER_INIT Optional<PhysicalAddress> SysFSSMBIOSDirectory::find_smbios_entry64bit_point()
{
+7 -7
View File
@@ -58,7 +58,7 @@ struct TypedMapping<T[]> {
};
template<typename T>
static ErrorOr<NonnullOwnPtr<TypedMapping<T>>> adopt_new_nonnull_own_typed_mapping(PhysicalAddress paddr, size_t length, Region::Access access = Region::Access::Read)
ErrorOr<NonnullOwnPtr<TypedMapping<T>>> adopt_new_nonnull_own_typed_mapping(PhysicalAddress paddr, size_t length, Region::Access access = Region::Access::Read)
{
auto mapping_length = TRY(page_round_up(paddr.offset_in_page() + length));
auto region = TRY(MM.allocate_mmio_kernel_region(paddr.page_base(), mapping_length, {}, access));
@@ -71,7 +71,7 @@ static ErrorOr<NonnullOwnPtr<TypedMapping<T>>> adopt_new_nonnull_own_typed_mappi
}
template<typename T>
static ErrorOr<TypedMapping<T>> map_typed(PhysicalAddress paddr, size_t length, Region::Access access = Region::Access::Read)
ErrorOr<TypedMapping<T>> map_typed(PhysicalAddress paddr, size_t length, Region::Access access = Region::Access::Read)
{
TypedMapping<T> table;
auto mapping_length = TRY(page_round_up(paddr.offset_in_page() + length));
@@ -83,19 +83,19 @@ static ErrorOr<TypedMapping<T>> map_typed(PhysicalAddress paddr, size_t length,
}
template<typename T>
static ErrorOr<TypedMapping<T>> map_typed(PhysicalAddress paddr)
ErrorOr<TypedMapping<T>> map_typed(PhysicalAddress paddr)
{
return map_typed<T>(paddr, sizeof(T));
}
template<typename T>
static ErrorOr<TypedMapping<T>> map_typed_writable(PhysicalAddress paddr)
ErrorOr<TypedMapping<T>> map_typed_writable(PhysicalAddress paddr)
{
return map_typed<T>(paddr, sizeof(T), Region::Access::Read | Region::Access::Write);
}
template<typename T>
static ErrorOr<NonnullOwnPtr<TypedMapping<T[]>>> adopt_new_nonnull_own_typed_mapping_array(PhysicalAddress paddr, size_t items, Region::Access access = Region::Access::Read)
ErrorOr<NonnullOwnPtr<TypedMapping<T[]>>> adopt_new_nonnull_own_typed_mapping_array(PhysicalAddress paddr, size_t items, Region::Access access = Region::Access::Read)
{
size_t length_in_bytes = items * sizeof(T);
auto mapping_length = TRY(page_round_up(paddr.offset_in_page() + length_in_bytes));
@@ -109,14 +109,14 @@ static ErrorOr<NonnullOwnPtr<TypedMapping<T[]>>> adopt_new_nonnull_own_typed_map
}
template<typename T>
static ErrorOr<TypedMapping<T[]>> map_typed_array(PhysicalAddress paddr, size_t items, Region::Access access = Region::Access::Read)
ErrorOr<TypedMapping<T[]>> map_typed_array(PhysicalAddress paddr, size_t items, Region::Access access = Region::Access::Read)
{
size_t length_in_bytes = items * sizeof(T);
return map_typed<T[]>(paddr, length_in_bytes, access);
}
template<typename T>
static ErrorOr<TypedMapping<T[]>> allocate_dma_region_as_typed_array(size_t items, StringView name, Region::Access access, MemoryType memory_type = MemoryType::NonCacheable)
ErrorOr<TypedMapping<T[]>> allocate_dma_region_as_typed_array(size_t items, StringView name, Region::Access access, MemoryType memory_type = MemoryType::NonCacheable)
{
size_t length_in_bytes = items * sizeof(T);
size_t mapping_length = TRY(page_round_up(length_in_bytes));
@@ -12,7 +12,7 @@
namespace Spreadsheet {
template<typename Callable>
static auto propagate_failure(Cell& cell, Callable&& steps)
auto propagate_failure(Cell& cell, Callable&& steps)
{
auto result_or_error = steps();
if (result_or_error.is_error())
+2 -2
View File
@@ -32,12 +32,12 @@ public:
return #klass##sv; \
} \
template<typename Klass = klass, class... Args> \
static NonnullRefPtr<klass> construct(Args&&... args) \
[[maybe_unused]] static NonnullRefPtr<klass> construct(Args&&... args) \
{ \
return adopt_ref(*new Klass(::forward<Args>(args)...)); \
} \
template<typename Klass = klass, class... Args> \
static ErrorOr<NonnullRefPtr<klass>> try_create(Args&&... args) \
[[maybe_unused]] static ErrorOr<NonnullRefPtr<klass>> try_create(Args&&... args) \
{ \
return adopt_nonnull_ref_or_enomem(new (nothrow) Klass(::forward<Args>(args)...)); \
}
@@ -19,7 +19,7 @@ UnsignedBigInteger ModularPower(UnsignedBigInteger const& b, UnsignedBigInteger
// it will allocate and free a lot of memory!
// Please use |ModularPower| if your use-case is modexp.
template<typename IntegerType>
static IntegerType Power(IntegerType const& b, IntegerType const& e)
IntegerType Power(IntegerType const& b, IntegerType const& e)
{
IntegerType ep { e };
IntegerType base { b };
@@ -56,7 +56,7 @@ static inline ErrorOr<u16> read_number(SeekableStream& stream)
}
template<typename TContext>
static ErrorOr<void> read_comment(TContext& context)
ErrorOr<void> read_comment(TContext& context)
{
auto& stream = *context.stream;
bool is_first_char = true;
@@ -76,7 +76,7 @@ static ErrorOr<void> read_comment(TContext& context)
}
template<typename TContext>
static ErrorOr<void> read_magic_number(TContext& context)
ErrorOr<void> read_magic_number(TContext& context)
{
if (TRY(context.stream->size()) < 2) {
dbgln_if(PORTABLE_IMAGE_LOADER_DEBUG, "There is no enough data for {}", TContext::FormatDetails::image_type);
@@ -103,7 +103,7 @@ static ErrorOr<void> read_magic_number(TContext& context)
}
template<typename TContext>
static ErrorOr<void> read_whitespace(TContext& context)
ErrorOr<void> read_whitespace(TContext& context)
{
auto& stream = *context.stream;
bool is_first_char = true;
@@ -135,21 +135,21 @@ static ErrorOr<void> read_whitespace(TContext& context)
}
template<typename TContext>
static ErrorOr<void> read_width(TContext& context)
ErrorOr<void> read_width(TContext& context)
{
context.width = TRY(read_number(*context.stream));
return {};
}
template<typename TContext>
static ErrorOr<void> read_height(TContext& context)
ErrorOr<void> read_height(TContext& context)
{
context.height = TRY(read_number(*context.stream));
return {};
}
template<typename TContext>
static ErrorOr<void> read_max_val(TContext& context)
ErrorOr<void> read_max_val(TContext& context)
{
context.format_details.max_val = TRY(read_number(*context.stream));
@@ -165,14 +165,14 @@ static ErrorOr<void> read_max_val(TContext& context)
}
template<typename TContext>
static ErrorOr<void> create_bitmap(TContext& context)
ErrorOr<void> create_bitmap(TContext& context)
{
context.bitmap = TRY(Bitmap::create(BitmapFormat::BGRx8888, { context.width, context.height }));
return {};
}
template<typename Context>
static ErrorOr<void> read_header(Context& context)
ErrorOr<void> read_header(Context& context)
{
TRY(read_magic_number(context));
@@ -195,10 +195,10 @@ static ErrorOr<void> read_header(Context& context)
}
template<typename Context>
static ErrorOr<void> read_pam_header(Context& context);
ErrorOr<void> read_pam_header(Context& context);
template<typename TContext>
static ErrorOr<void> decode(TContext& context)
ErrorOr<void> decode(TContext& context)
{
VERIFY(context.state == TContext::State::HeaderDecoded);
+1 -1
View File
@@ -42,7 +42,7 @@ private:
};
template<typename Callable, typename T = EquivalentFunctionType<Callable>>
static NonnullGCPtr<HeapFunction<T>> create_heap_function(Heap& heap, Callable&& function)
NonnullGCPtr<HeapFunction<T>> create_heap_function(Heap& heap, Callable&& function)
{
return HeapFunction<T>::create(heap, Function<T> { forward<Callable>(function) });
}
-17
View File
@@ -99,23 +99,6 @@ static ErrorOr<String> escape_for_string_literal(StringView string)
ErrorOr<void> print_value(JS::PrintContext&, JS::Value value, HashTable<JS::Object*>& seen_objects);
template<typename T>
ErrorOr<void> print_value(JS::PrintContext& print_context, JS::ThrowCompletionOr<T> value_or_error, HashTable<JS::Object*>& seen_objects)
{
if (value_or_error.is_error()) {
auto error = value_or_error.release_error();
// We can't explicitly check for OOM because InternalError does not store the ErrorType
VERIFY(error.value().has_value());
VERIFY(error.value()->is_object());
VERIFY(is<JS::InternalError>(error.value()->as_object()));
return Error::from_errno(ENOMEM);
}
return print_value(print_context, value_or_error.release_value(), seen_objects);
}
ErrorOr<String> strip_ansi(StringView format_string)
{
if (format_string.is_empty())
@@ -172,7 +172,7 @@ inline size_t array_buffer_byte_length(ArrayBuffer const& array_buffer, ArrayBuf
// 25.1.3.14 RawBytesToNumeric ( type, rawBytes, isLittleEndian ), https://tc39.es/ecma262/#sec-rawbytestonumeric
template<typename T>
static Value raw_bytes_to_numeric(VM& vm, Bytes raw_value, bool is_little_endian)
Value raw_bytes_to_numeric(VM& vm, Bytes raw_value, bool is_little_endian)
{
// 1. Let elementSize be the Element Size value specified in Table 70 for Element Type type.
// NOTE: Used in step 6, but not needed with our implementation of that step.
@@ -290,7 +290,7 @@ Value ArrayBuffer::get_value(size_t byte_index, [[maybe_unused]] bool is_typed_a
// 25.1.3.17 NumericToRawBytes ( type, value, isLittleEndian ), https://tc39.es/ecma262/#sec-numerictorawbytes
template<typename T>
static void numeric_to_raw_bytes(VM& vm, Value value, bool is_little_endian, Bytes raw_bytes)
void numeric_to_raw_bytes(VM& vm, Value value, bool is_little_endian, Bytes raw_bytes)
{
VERIFY(value.is_number() || value.is_bigint());
using UnderlyingBufferDataType = Conditional<IsSame<ClampedU8, T>, u8, T>;
+1 -1
View File
@@ -353,7 +353,7 @@ private:
};
template<typename GlobalObjectType, typename... Args>
[[nodiscard]] static NonnullOwnPtr<ExecutionContext> create_simple_execution_context(VM& vm, Args&&... args)
[[nodiscard]] NonnullOwnPtr<ExecutionContext> create_simple_execution_context(VM& vm, Args&&... args)
{
auto root_execution_context = MUST(Realm::initialize_host_defined_realm(
vm,
-4
View File
@@ -15,8 +15,6 @@
#include <LibPDF/Forward.h>
#ifdef PDF_DEBUG
namespace {
template<PDF::IsObject T>
char const* object_name()
{
@@ -29,8 +27,6 @@ char const* object_name()
VERIFY_NOT_REACHED();
}
}
#endif
namespace PDF {
+1 -1
View File
@@ -16,7 +16,7 @@
namespace PDF {
template<typename T, typename... Args>
static NonnullRefPtr<T> make_object(Args... args)
NonnullRefPtr<T> make_object(Args... args)
requires(IsBaseOf<Object, T>)
{
return adopt_ref(*new T(forward<Args>(args)...));
@@ -70,7 +70,7 @@ struct ColorStopListElement {
using LinearColorStopListElement = ColorStopListElement<LengthPercentage>;
using AngularColorStopListElement = ColorStopListElement<AnglePercentage>;
static void serialize_color_stop_list(StringBuilder& builder, auto const& color_stop_list)
void serialize_color_stop_list(StringBuilder& builder, auto const& color_stop_list)
{
bool first = true;
for (auto const& element : color_stop_list) {
@@ -2156,8 +2156,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
return returned_pending_response;
}
#if defined(WEB_FETCH_DEBUG)
static void log_load_request(auto const& load_request)
[[maybe_unused]] static void log_load_request(auto const& load_request)
{
dbgln("Fetch: Invoking ResourceLoader");
dbgln("> {} {} HTTP/1.1", load_request.method(), load_request.url());
@@ -2168,7 +2167,7 @@ static void log_load_request(auto const& load_request)
dbgln("> {}", line);
}
static void log_response(auto const& status_code, auto const& headers, auto const& data)
[[maybe_unused]] static void log_response(auto const& status_code, auto const& headers, auto const& data)
{
dbgln("< HTTP/1.1 {}", status_code.value_or(0));
for (auto const& [name, value] : headers.headers())
@@ -2177,7 +2176,6 @@ static void log_response(auto const& status_code, auto const& headers, auto cons
for (auto line : StringView { data }.split_view('\n', SplitBehavior::KeepEmpty))
dbgln("< {}", line);
}
#endif
// https://fetch.spec.whatwg.org/#concept-http-network-fetch
// Drop-in replacement for 'HTTP-network fetch', but obviously non-standard :^)
@@ -16,7 +16,7 @@
namespace Web::WebDriver {
template<typename PropertyType = ByteString>
static ErrorOr<PropertyType, WebDriver::Error> get_property(JsonObject const& payload, StringView key)
ErrorOr<PropertyType, WebDriver::Error> get_property(JsonObject const& payload, StringView key)
{
auto property = payload.get(key);
@@ -68,7 +68,7 @@ static ErrorOr<PropertyType, WebDriver::Error> get_property(JsonObject const& pa
}
template<typename PropertyType = ByteString>
static ErrorOr<PropertyType, WebDriver::Error> get_property(JsonValue const& payload, StringView key)
ErrorOr<PropertyType, WebDriver::Error> get_property(JsonValue const& payload, StringView key)
{
if (!payload.is_object())
return WebDriver::Error::from_code(ErrorCode::InvalidArgument, "Payload is not a JSON object");
@@ -76,7 +76,7 @@ static ErrorOr<PropertyType, WebDriver::Error> get_property(JsonValue const& pay
}
template<typename PropertyType = ByteString>
static ErrorOr<Optional<PropertyType>, WebDriver::Error> get_optional_property(JsonObject const& object, StringView key)
ErrorOr<Optional<PropertyType>, WebDriver::Error> get_optional_property(JsonObject const& object, StringView key)
{
if (!object.has(key))
return OptionalNone {};
@@ -84,7 +84,7 @@ static ErrorOr<Optional<PropertyType>, WebDriver::Error> get_optional_property(J
}
template<Arithmetic PropertyType>
static ErrorOr<PropertyType, WebDriver::Error> get_property_with_limits(JsonObject const& object, StringView key, Optional<PropertyType> min, Optional<PropertyType> max)
ErrorOr<PropertyType, WebDriver::Error> get_property_with_limits(JsonObject const& object, StringView key, Optional<PropertyType> min, Optional<PropertyType> max)
{
auto value = TRY(get_property<PropertyType>(object, key));
@@ -97,7 +97,7 @@ static ErrorOr<PropertyType, WebDriver::Error> get_property_with_limits(JsonObje
}
template<Arithmetic PropertyType>
static ErrorOr<Optional<PropertyType>, WebDriver::Error> get_optional_property_with_limits(JsonObject const& object, StringView key, Optional<PropertyType> min, Optional<PropertyType> max)
ErrorOr<Optional<PropertyType>, WebDriver::Error> get_optional_property_with_limits(JsonObject const& object, StringView key, Optional<PropertyType> min, Optional<PropertyType> max)
{
if (!object.has(key))
return OptionalNone {};