Skip to content

Commit

Permalink
Mark all single-arg ctors in src/runtime as explicit (#7707)
Browse files Browse the repository at this point in the history
Minor code hygiene fix, done as byproduct of #7704
  • Loading branch information
steven-johnson authored Jul 25, 2023
1 parent df902e7 commit ab3ff3a
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/runtime/HalideBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct AllocationHeader {
std::atomic<int> ref_count;

// Note that ref_count always starts at 1
AllocationHeader(void (*deallocate_fn)(void *))
explicit AllocationHeader(void (*deallocate_fn)(void *))
: deallocate_fn(deallocate_fn), ref_count(1) {
}
};
Expand Down Expand Up @@ -298,7 +298,7 @@ class Buffer {
// operation as well.
struct DevRefCountCropped : DeviceRefCount {
Buffer<T, Dims, InClassDimStorage> cropped_from;
DevRefCountCropped(const Buffer<T, Dims, InClassDimStorage> &cropped_from)
explicit DevRefCountCropped(const Buffer<T, Dims, InClassDimStorage> &cropped_from)
: cropped_from(cropped_from) {
ownership = BufferDeviceOwnership::Cropped;
}
Expand Down Expand Up @@ -608,7 +608,7 @@ class Buffer {
return {min() + extent()};
}

Dimension(const halide_dimension_t &dim)
explicit Dimension(const halide_dimension_t &dim)
: d(dim) {
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class Context {
CUcontext context = nullptr;

// Constructor sets 'status' if any error occurs.
ALWAYS_INLINE Context(void *user_context)
ALWAYS_INLINE explicit Context(void *user_context)
: user_context(user_context) {
#ifdef DEBUG_RUNTIME
halide_start_clock(user_context);
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/internal/memory_arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class MemoryArena {
uint32_t maximum_block_count = 0;
};

MemoryArena(void *user_context, const Config &config = default_config(),
const SystemMemoryAllocatorFns &allocator = default_allocator());
explicit MemoryArena(void *user_context, const Config &config = default_config(),
const SystemMemoryAllocatorFns &allocator = default_allocator());

~MemoryArena();

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/internal/pointer_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PointerTable {
public:
static constexpr size_t default_capacity = 32; // smallish

PointerTable(void *user_context, size_t initial_capacity = 0, const SystemMemoryAllocatorFns &sma = default_allocator());
explicit PointerTable(void *user_context, size_t initial_capacity = 0, const SystemMemoryAllocatorFns &sma = default_allocator());
PointerTable(const PointerTable &other);
~PointerTable();

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/internal/string_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct StringUtils {
//
class StringStorage {
public:
StringStorage(void *user_context = nullptr, uint32_t capacity = 0, const SystemMemoryAllocatorFns &sma = default_allocator());
explicit StringStorage(void *user_context = nullptr, uint32_t capacity = 0, const SystemMemoryAllocatorFns &sma = default_allocator());
StringStorage(const StringStorage &other) = default;
~StringStorage();

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/internal/string_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class StringTable {
StringTable(const StringTable &) = delete;
StringTable &operator=(const StringTable &) = delete;

StringTable(const SystemMemoryAllocatorFns &allocator = StringStorage::default_allocator());
explicit StringTable(const SystemMemoryAllocatorFns &allocator = StringStorage::default_allocator());
StringTable(void *user_context, size_t capacity, const SystemMemoryAllocatorFns &allocator = StringStorage::default_allocator());
StringTable(void *user_context, const char **array, size_t count, const SystemMemoryAllocatorFns &allocator = StringStorage::default_allocator());
~StringTable();
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class ClContext {
cl_command_queue cmd_queue = nullptr;

// Constructor sets 'status' if any occurs.
ALWAYS_INLINE ClContext(void *user_context)
ALWAYS_INLINE explicit ClContext(void *user_context)
: user_context(user_context) {
if (clCreateContext == nullptr) {
status = load_libopencl(user_context);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/profiler_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LockProfiler {
halide_profiler_state *state;

public:
LockProfiler(halide_profiler_state *s)
explicit LockProfiler(halide_profiler_state *s)
: state(s) {
#if TIMER_PROFILING
halide_disable_timer_interrupt();
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/scoped_mutex_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Internal {
struct ScopedMutexLock {
halide_mutex *mutex;

ALWAYS_INLINE ScopedMutexLock(halide_mutex *mutex)
ALWAYS_INLINE explicit ScopedMutexLock(halide_mutex *mutex)
: mutex(mutex) {
halide_mutex_lock(mutex);
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/scoped_spin_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct ScopedSpinLock {

volatile AtomicFlag *const flag;

ALWAYS_INLINE ScopedSpinLock(volatile AtomicFlag *flag)
ALWAYS_INLINE explicit ScopedSpinLock(volatile AtomicFlag *flag)
: flag(flag) {
while (__atomic_test_and_set(flag, __ATOMIC_ACQUIRE)) {
// nothing
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/synchronization_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ WEAK int parking_control::unpark_requeue(uintptr_t addr_from, uintptr_t addr_to,
struct mutex_parking_control final : public parking_control {
uintptr_t *const lock_state;

ALWAYS_INLINE mutex_parking_control(uintptr_t *lock_state)
ALWAYS_INLINE explicit mutex_parking_control(uintptr_t *lock_state)
: lock_state(lock_state) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/vulkan_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class VulkanContext {
uint32_t queue_family_index = 0; // used for operations requiring queue family
halide_error_code_t error = halide_error_code_success;

HALIDE_ALWAYS_INLINE VulkanContext(void *user_context)
HALIDE_ALWAYS_INLINE explicit VulkanContext(void *user_context)
: user_context(user_context) {

int result = halide_vulkan_acquire_context(user_context,
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/webgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class WgpuContext {

int error_code = 0;

ALWAYS_INLINE WgpuContext(void *user_context)
ALWAYS_INLINE explicit WgpuContext(void *user_context)
: user_context(user_context) {
error_code = halide_webgpu_acquire_context(
user_context, &instance, &adapter, &device, &staging_buffer);
Expand Down

0 comments on commit ab3ff3a

Please sign in to comment.