Fixup explicit on some constructors.

This CL adds explicit to various single argument constructors. The
explicit is removed from zero argument constructors. None of these
changes required call sites to change.

Bug: dawn:1339
Change-Id: I7dfcf1b393e7dd379e29cd9bc613cb0626a9a967
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86365
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2022-04-12 17:44:41 +00:00 committed by Dawn LUCI CQ
parent 012098a86b
commit d53cb2ae67
46 changed files with 53 additions and 50 deletions

View File

@ -34,13 +34,13 @@ T roundUp(const T value, const T alignment) {
template <size_t N, typename T> template <size_t N, typename T>
class BitSetIterator final { class BitSetIterator final {
public: public:
BitSetIterator(const std::bitset<N>& bitset); explicit BitSetIterator(const std::bitset<N>& bitset);
BitSetIterator(const BitSetIterator& other); BitSetIterator(const BitSetIterator& other);
BitSetIterator& operator=(const BitSetIterator& other); BitSetIterator& operator=(const BitSetIterator& other);
class Iterator final { class Iterator final {
public: public:
Iterator(const std::bitset<N>& bits); explicit Iterator(const std::bitset<N>& bits);
Iterator& operator++(); Iterator& operator++();
bool operator==(const Iterator& other) const; bool operator==(const Iterator& other) const;

View File

@ -235,7 +235,7 @@ class LinkedList {
template <typename T> template <typename T>
class LinkedListIterator { class LinkedListIterator {
public: public:
LinkedListIterator(LinkNode<T>* node) : current_(node), next_(node->next()) { explicit LinkedListIterator(LinkNode<T>* node) : current_(node), next_(node->next()) {
} }
// We keep an early reference to the next node in the list so that even if the current element // We keep an early reference to the next node in the list so that even if the current element

View File

@ -22,7 +22,7 @@
class RefCounted { class RefCounted {
public: public:
RefCounted(uint64_t payload = 0); explicit RefCounted(uint64_t payload = 0);
uint64_t GetRefCountForTesting() const; uint64_t GetRefCountForTesting() const;
uint64_t GetRefCountPayload() const; uint64_t GetRefCountPayload() const;

View File

@ -30,7 +30,7 @@ namespace ityp {
static_assert(sizeof(I) <= sizeof(size_t)); static_assert(sizeof(I) <= sizeof(size_t));
constexpr bitset(const Base& rhs) : Base(rhs) { explicit constexpr bitset(const Base& rhs) : Base(rhs) {
} }
public: public:

View File

@ -31,7 +31,7 @@ namespace ityp {
public: public:
stack_vec() : Base() { stack_vec() : Base() {
} }
stack_vec(Index size) : Base() { explicit stack_vec(Index size) : Base() {
this->container().resize(static_cast<I>(size)); this->container().resize(static_cast<I>(size));
} }

View File

@ -74,7 +74,7 @@ namespace dawn::native {
} }
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
BindGroupBase(DeviceBase* device); explicit BindGroupBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
~BindGroupBase() override; ~BindGroupBase() override;

View File

@ -135,7 +135,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
BindGroupLayoutBase(DeviceBase* device); explicit BindGroupLayoutBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
template <typename BindGroup> template <typename BindGroup>

View File

@ -35,7 +35,7 @@ namespace dawn::native {
// //
class BuddyAllocator { class BuddyAllocator {
public: public:
BuddyAllocator(uint64_t maxSize); explicit BuddyAllocator(uint64_t maxSize);
~BuddyAllocator(); ~BuddyAllocator();
// Required methods. // Required methods.

View File

@ -46,7 +46,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
CommandBufferBase(DeviceBase* device); explicit CommandBufferBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
CommandIterator mCommands; CommandIterator mCommands;

View File

@ -71,7 +71,7 @@ namespace dawn::native {
ComputePipelineBase* ComputePipelineBase::MakeError(DeviceBase* device) { ComputePipelineBase* ComputePipelineBase::MakeError(DeviceBase* device) {
class ErrorComputePipeline final : public ComputePipelineBase { class ErrorComputePipeline final : public ComputePipelineBase {
public: public:
ErrorComputePipeline(DeviceBase* device) explicit ErrorComputePipeline(DeviceBase* device)
: ComputePipelineBase(device, ObjectBase::kError) { : ComputePipelineBase(device, ObjectBase::kError) {
} }

View File

@ -43,7 +43,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
ComputePipelineBase(DeviceBase* device); explicit ComputePipelineBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
private: private:

View File

@ -28,7 +28,8 @@ namespace dawn::native {
namespace { namespace {
struct ComboDeprecatedDawnDeviceDescriptor : DeviceDescriptor { struct ComboDeprecatedDawnDeviceDescriptor : DeviceDescriptor {
ComboDeprecatedDawnDeviceDescriptor(const DawnDeviceDescriptor* deviceDescriptor) { explicit ComboDeprecatedDawnDeviceDescriptor(
const DawnDeviceDescriptor* deviceDescriptor) {
dawn::WarningLog() << "DawnDeviceDescriptor is deprecated. Please use " dawn::WarningLog() << "DawnDeviceDescriptor is deprecated. Please use "
"WGPUDeviceDescriptor instead."; "WGPUDeviceDescriptor instead.";

View File

@ -32,7 +32,7 @@ namespace dawn::native {
class DynamicUploader { class DynamicUploader {
public: public:
DynamicUploader(DeviceBase* device); explicit DynamicUploader(DeviceBase* device);
~DynamicUploader() = default; ~DynamicUploader() = default;
// We add functions to Release StagingBuffers to the DynamicUploader as there's // We add functions to Release StagingBuffers to the DynamicUploader as there's

View File

@ -28,14 +28,15 @@ namespace dawn::native {
using U = std::underlying_type_t<T>; using U = std::underlying_type_t<T>;
public: public:
EnumMaskIterator(const T& mask) : mBitSetIterator(std::bitset<N>(static_cast<U>(mask))) { explicit EnumMaskIterator(const T& mask)
: mBitSetIterator(std::bitset<N>(static_cast<U>(mask))) {
// If you hit this ASSERT it means that you forgot to update EnumBitmaskSize<T>::value; // If you hit this ASSERT it means that you forgot to update EnumBitmaskSize<T>::value;
ASSERT(U(mask) == 0 || Log2(uint64_t(U(mask))) < N); ASSERT(U(mask) == 0 || Log2(uint64_t(U(mask))) < N);
} }
class Iterator final { class Iterator final {
public: public:
Iterator(const typename BitSetIterator<N, U>::Iterator& iter) : mIter(iter) { explicit Iterator(const typename BitSetIterator<N, U>::Iterator& iter) : mIter(iter) {
} }
Iterator& operator++() { Iterator& operator++() {

View File

@ -54,7 +54,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
ExternalTextureBase(DeviceBase* device); explicit ExternalTextureBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
~ExternalTextureBase() override; ~ExternalTextureBase() override;

View File

@ -49,7 +49,7 @@ namespace dawn::native {
class PerStage { class PerStage {
public: public:
PerStage() = default; PerStage() = default;
PerStage(const T& initialValue) { explicit PerStage(const T& initialValue) {
mData.fill(initialValue); mData.fill(initialValue);
} }

View File

@ -43,7 +43,7 @@ namespace dawn::native {
// protected by mMutex. // protected by mMutex.
class PersistentCache { class PersistentCache {
public: public:
PersistentCache(DeviceBase* device); explicit PersistentCache(DeviceBase* device);
// Combines load/store operations into a single call. // Combines load/store operations into a single call.
// If the load was successful, a non-empty blob is returned to the caller. // If the load was successful, a non-empty blob is returned to the caller.

View File

@ -81,7 +81,7 @@ namespace dawn::native {
PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag); PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
PipelineBase(DeviceBase* device); explicit PipelineBase(DeviceBase* device);
private: private:
MaybeError ValidateGetBindGroupLayout(uint32_t group); MaybeError ValidateGetBindGroupLayout(uint32_t group);

View File

@ -84,7 +84,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
PipelineLayoutBase(DeviceBase* device); explicit PipelineLayoutBase(DeviceBase* device);
PipelineLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag); PipelineLayoutBase(DeviceBase* device, ObjectBase::ErrorTag tag);
void DestroyImpl() override; void DestroyImpl() override;

View File

@ -30,7 +30,7 @@ namespace dawn::native {
// the pool and made AVAILABLE. // the pool and made AVAILABLE.
class PooledResourceMemoryAllocator : public ResourceHeapAllocator { class PooledResourceMemoryAllocator : public ResourceHeapAllocator {
public: public:
PooledResourceMemoryAllocator(ResourceHeapAllocator* heapAllocator); explicit PooledResourceMemoryAllocator(ResourceHeapAllocator* heapAllocator);
~PooledResourceMemoryAllocator() override = default; ~PooledResourceMemoryAllocator() override = default;
ResultOrError<std::unique_ptr<ResourceHeapBase>> AllocateResourceHeap( ResultOrError<std::unique_ptr<ResourceHeapBase>> AllocateResourceHeap(

View File

@ -27,7 +27,7 @@ namespace dawn::native {
class ErrorQuerySet final : public QuerySetBase { class ErrorQuerySet final : public QuerySetBase {
public: public:
ErrorQuerySet(DeviceBase* device) : QuerySetBase(device, ObjectBase::kError) { explicit ErrorQuerySet(DeviceBase* device) : QuerySetBase(device, ObjectBase::kError) {
} }
private: private:

View File

@ -48,7 +48,7 @@ namespace dawn::native {
QuerySetBase(DeviceBase* device, ObjectBase::ErrorTag tag); QuerySetBase(DeviceBase* device, ObjectBase::ErrorTag tag);
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
QuerySetBase(DeviceBase* device); explicit QuerySetBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
~QuerySetBase() override; ~QuerySetBase() override;

View File

@ -154,7 +154,7 @@ namespace dawn::native {
class ErrorQueue : public QueueBase { class ErrorQueue : public QueueBase {
public: public:
ErrorQueue(DeviceBase* device) : QueueBase(device, ObjectBase::kError) { explicit ErrorQueue(DeviceBase* device) : QueueBase(device, ObjectBase::kError) {
} }
private: private:

View File

@ -655,7 +655,7 @@ namespace dawn::native {
RenderPipelineBase* RenderPipelineBase::MakeError(DeviceBase* device) { RenderPipelineBase* RenderPipelineBase::MakeError(DeviceBase* device) {
class ErrorRenderPipeline final : public RenderPipelineBase { class ErrorRenderPipeline final : public RenderPipelineBase {
public: public:
ErrorRenderPipeline(DeviceBase* device) explicit ErrorRenderPipeline(DeviceBase* device)
: RenderPipelineBase(device, ObjectBase::kError) { : RenderPipelineBase(device, ObjectBase::kError) {
} }

View File

@ -112,7 +112,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
RenderPipelineBase(DeviceBase* device); explicit RenderPipelineBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
private: private:

View File

@ -56,7 +56,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
SamplerBase(DeviceBase* device); explicit SamplerBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
private: private:

View File

@ -974,7 +974,7 @@ namespace dawn::native {
class TintSource { class TintSource {
public: public:
template <typename... ARGS> template <typename... ARGS>
TintSource(ARGS&&... args) : file(std::forward<ARGS>(args)...) { explicit TintSource(ARGS&&... args) : file(std::forward<ARGS>(args)...) {
} }
tint::Source::File file; tint::Source::File file;

View File

@ -284,7 +284,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
ShaderModuleBase(DeviceBase* device); explicit ShaderModuleBase(DeviceBase* device);
void DestroyImpl() override; void DestroyImpl() override;
MaybeError InitializeBase(ShaderModuleParseResult* parseResult); MaybeError InitializeBase(ShaderModuleParseResult* parseResult);

View File

@ -21,7 +21,7 @@ namespace dawn::native {
class StagingBufferBase { class StagingBufferBase {
public: public:
StagingBufferBase(size_t size); explicit StagingBufferBase(size_t size);
virtual ~StagingBufferBase() = default; virtual ~StagingBufferBase() = default;
virtual MaybeError Initialize() = 0; virtual MaybeError Initialize() = 0;

View File

@ -28,7 +28,8 @@ namespace dawn::native {
class ErrorSwapChain final : public SwapChainBase { class ErrorSwapChain final : public SwapChainBase {
public: public:
ErrorSwapChain(DeviceBase* device) : SwapChainBase(device, ObjectBase::kError) { explicit ErrorSwapChain(DeviceBase* device)
: SwapChainBase(device, ObjectBase::kError) {
} }
private: private:

View File

@ -32,7 +32,7 @@ namespace dawn::native {
class SwapChainBase : public ApiObjectBase { class SwapChainBase : public ApiObjectBase {
public: public:
SwapChainBase(DeviceBase* device); explicit SwapChainBase(DeviceBase* device);
static SwapChainBase* MakeError(DeviceBase* device); static SwapChainBase* MakeError(DeviceBase* device);

View File

@ -145,7 +145,7 @@ namespace dawn::native {
protected: protected:
// Constructor used only for mocking and testing. // Constructor used only for mocking and testing.
TextureViewBase(TextureBase* texture); explicit TextureViewBase(TextureBase* texture);
void DestroyImpl() override; void DestroyImpl() override;
private: private:

View File

@ -25,7 +25,7 @@ namespace dawn::native {
// reported to the given device. // reported to the given device.
class ScopedTintICEHandler : public NonCopyable { class ScopedTintICEHandler : public NonCopyable {
public: public:
ScopedTintICEHandler(DeviceBase* device); explicit ScopedTintICEHandler(DeviceBase* device);
~ScopedTintICEHandler(); ~ScopedTintICEHandler();
private: private:

View File

@ -21,7 +21,7 @@ namespace dawn::native::metal {
class Backend : public BackendConnection { class Backend : public BackendConnection {
public: public:
Backend(InstanceBase* instance); explicit Backend(InstanceBase* instance);
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters() override; std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters() override;
ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters( ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters(

View File

@ -68,7 +68,8 @@ namespace dawn::native::null {
class Backend : public BackendConnection { class Backend : public BackendConnection {
public: public:
Backend(InstanceBase* instance) : BackendConnection(instance, wgpu::BackendType::Null) { explicit Backend(InstanceBase* instance)
: BackendConnection(instance, wgpu::BackendType::Null) {
} }
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters() override { std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters() override {

View File

@ -168,7 +168,7 @@ namespace dawn::native::null {
class Adapter : public AdapterBase { class Adapter : public AdapterBase {
public: public:
Adapter(InstanceBase* instance); explicit Adapter(InstanceBase* instance);
~Adapter() override; ~Adapter() override;
// AdapterBase Implementation // AdapterBase Implementation

View File

@ -74,7 +74,7 @@ namespace dawn::native::utils {
wgpu::TextureFormat format, wgpu::TextureFormat format,
wgpu::TextureViewDimension viewDimension = wgpu::TextureViewDimension::e2D); wgpu::TextureViewDimension viewDimension = wgpu::TextureViewDimension::e2D);
BindingLayoutEntryInitializationHelper(const BindGroupLayoutEntry& entry); explicit BindingLayoutEntryInitializationHelper(const BindGroupLayoutEntry& entry);
}; };
ResultOrError<Ref<BindGroupLayoutBase>> MakeBindGroupLayout( ResultOrError<Ref<BindGroupLayoutBase>> MakeBindGroupLayout(

View File

@ -68,7 +68,7 @@ namespace dawn::native::vulkan {
class Backend : public BackendConnection { class Backend : public BackendConnection {
public: public:
Backend(InstanceBase* instance); explicit Backend(InstanceBase* instance);
~Backend() override; ~Backend() override;
MaybeError Initialize(); MaybeError Initialize();

View File

@ -25,7 +25,7 @@ namespace dawn::native::vulkan {
class FencedDeleter { class FencedDeleter {
public: public:
FencedDeleter(Device* device); explicit FencedDeleter(Device* device);
~FencedDeleter(); ~FencedDeleter();
void DeleteWhenUnused(VkBuffer buffer); void DeleteWhenUnused(VkBuffer buffer);

View File

@ -76,7 +76,7 @@ namespace dawn::native::vulkan {
// TODO(cwallez@chromium.org): Make it an LRU cache somehow? // TODO(cwallez@chromium.org): Make it an LRU cache somehow?
class RenderPassCache { class RenderPassCache {
public: public:
RenderPassCache(Device* device); explicit RenderPassCache(Device* device);
~RenderPassCache(); ~RenderPassCache();
ResultOrError<VkRenderPass> GetRenderPass(const RenderPassCacheQuery& query); ResultOrError<VkRenderPass> GetRenderPass(const RenderPassCacheQuery& query);

View File

@ -39,7 +39,7 @@ namespace dawn::native::vulkan {
class ResourceMemoryAllocator { class ResourceMemoryAllocator {
public: public:
ResourceMemoryAllocator(Device* device); explicit ResourceMemoryAllocator(Device* device);
~ResourceMemoryAllocator(); ~ResourceMemoryAllocator();
ResultOrError<ResourceMemoryAllocation> Allocate(const VkMemoryRequirements& requirements, ResultOrError<ResourceMemoryAllocation> Allocate(const VkMemoryRequirements& requirements,

View File

@ -319,7 +319,7 @@ namespace dawn::native::vulkan {
private: private:
// Private. Use VkResult::WrapUnsafe instead. // Private. Use VkResult::WrapUnsafe instead.
constexpr VkResult(::VkResult value) : mValue(value) { explicit constexpr VkResult(::VkResult value) : mValue(value) {
} }
::VkResult mValue; ::VkResult mValue;

View File

@ -53,8 +53,7 @@ namespace {
class AsyncWaitableEvent final : public dawn::platform::WaitableEvent { class AsyncWaitableEvent final : public dawn::platform::WaitableEvent {
public: public:
explicit AsyncWaitableEvent() AsyncWaitableEvent() : mWaitableEventImpl(std::make_shared<AsyncWaitableEventImpl>()) {
: mWaitableEventImpl(std::make_shared<AsyncWaitableEventImpl>()) {
} }
void Wait() override { void Wait() override {

View File

@ -22,7 +22,7 @@ namespace utils {
class TerribleCommandBuffer : public dawn::wire::CommandSerializer { class TerribleCommandBuffer : public dawn::wire::CommandSerializer {
public: public:
TerribleCommandBuffer(); TerribleCommandBuffer();
TerribleCommandBuffer(dawn::wire::CommandHandler* handler); explicit TerribleCommandBuffer(dawn::wire::CommandHandler* handler);
void SetHandler(dawn::wire::CommandHandler* handler); void SetHandler(dawn::wire::CommandHandler* handler);

View File

@ -28,7 +28,7 @@ namespace dawn::wire {
class ChunkedCommandSerializer { class ChunkedCommandSerializer {
public: public:
ChunkedCommandSerializer(CommandSerializer* serializer); explicit ChunkedCommandSerializer(CommandSerializer* serializer);
template <typename Cmd> template <typename Cmd>
void SerializeCommand(const Cmd& cmd) { void SerializeCommand(const Cmd& cmd) {

View File

@ -26,7 +26,7 @@ namespace dawn::wire::server {
public: public:
class MockReadHandle : public ReadHandle { class MockReadHandle : public ReadHandle {
public: public:
MockReadHandle(MockMemoryTransferService* service); explicit MockReadHandle(MockMemoryTransferService* service);
~MockReadHandle() override; ~MockReadHandle() override;
size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) override; size_t SizeOfSerializeDataUpdate(size_t offset, size_t size) override;
@ -41,7 +41,7 @@ namespace dawn::wire::server {
class MockWriteHandle : public WriteHandle { class MockWriteHandle : public WriteHandle {
public: public:
MockWriteHandle(MockMemoryTransferService* service); explicit MockWriteHandle(MockMemoryTransferService* service);
~MockWriteHandle() override; ~MockWriteHandle() override;
bool DeserializeDataUpdate(const void* deserializePointer, bool DeserializeDataUpdate(const void* deserializePointer,