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>
class BitSetIterator final {
public:
BitSetIterator(const std::bitset<N>& bitset);
explicit BitSetIterator(const std::bitset<N>& bitset);
BitSetIterator(const BitSetIterator& other);
BitSetIterator& operator=(const BitSetIterator& other);
class Iterator final {
public:
Iterator(const std::bitset<N>& bits);
explicit Iterator(const std::bitset<N>& bits);
Iterator& operator++();
bool operator==(const Iterator& other) const;

View File

@ -235,7 +235,7 @@ class LinkedList {
template <typename T>
class LinkedListIterator {
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -32,7 +32,7 @@ namespace dawn::native {
class DynamicUploader {
public:
DynamicUploader(DeviceBase* device);
explicit DynamicUploader(DeviceBase* device);
~DynamicUploader() = default;
// 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>;
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;
ASSERT(U(mask) == 0 || Log2(uint64_t(U(mask))) < N);
}
class Iterator final {
public:
Iterator(const typename BitSetIterator<N, U>::Iterator& iter) : mIter(iter) {
explicit Iterator(const typename BitSetIterator<N, U>::Iterator& iter) : mIter(iter) {
}
Iterator& operator++() {

View File

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

View File

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

View File

@ -43,7 +43,7 @@ namespace dawn::native {
// protected by mMutex.
class PersistentCache {
public:
PersistentCache(DeviceBase* device);
explicit PersistentCache(DeviceBase* device);
// Combines load/store operations into a single call.
// 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);
// Constructor used only for mocking and testing.
PipelineBase(DeviceBase* device);
explicit PipelineBase(DeviceBase* device);
private:
MaybeError ValidateGetBindGroupLayout(uint32_t group);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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