[dawn] Remove implicit-bool-conversion from clang tidy negative list Ran "run-clang-tidy" on all src/* and fixed known issues. Skip-Clang-Tidy-Checks: modernize-use-starts-ends-with Skip-Clang-Tidy-Checks: readability-container-contains Bug: 42250024 Change-Id: I217b80ff6ee78ac6db50274ddd8adcd716e96461 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/234095 Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: Peter McNeeley <petermcneeley@google.com>
diff --git a/.clang-tidy b/.clang-tidy index 048820b..51df115 100644 --- a/.clang-tidy +++ b/.clang-tidy
@@ -144,7 +144,6 @@ -readability-else-after-return,\ -readability-function-cognitive-complexity,\ -readability-identifier-length,\ - -readability-implicit-bool-conversion,\ -readability-inconsistent-declaration-parameter-name,\ -readability-isolate-declaration,\ -readability-magic-numbers,\ @@ -170,3 +169,7 @@ CheckOptions: - key: cppcoreguidelines-avoid-do-while.IgnoreMacros value: true + - key: readability-implicit-bool-conversion.AllowIntegerConditions + value: true + - key: readability-implicit-bool-conversion.AllowPointerConditions + value: true
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 69cdc13..ad206f1 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -122,6 +122,7 @@ "infra/config/global/main.star", # Infra settings "infra/kokoro/windows/build.bat", # External URL "src/dawn/common/GPUInfo.cpp", # External URL + "src/dawn/common/ThreadLocal.cpp", # External URL "src/dawn/native/metal/BackendMTL.mm", # OSX Constant "src/dawn/native/vulkan/SamplerVk.cpp", # External URL "src/dawn/native/vulkan/TextureVk.cpp", # External URL
diff --git a/src/dawn/common/ThreadLocal.cpp b/src/dawn/common/ThreadLocal.cpp index 9330254..bff3ed4 100644 --- a/src/dawn/common/ThreadLocal.cpp +++ b/src/dawn/common/ThreadLocal.cpp
@@ -69,7 +69,7 @@ } bool IsThreadAlive(ThreadUniqueId ThreadUniqueId) { - return GetAliveThreads()->count(ThreadUniqueId); + return GetAliveThreads()->count(ThreadUniqueId) != 0u; } } // namespace dawn
diff --git a/src/dawn/native/AttachmentState.cpp b/src/dawn/native/AttachmentState.cpp index 62e06a7..9c82a807 100644 --- a/src/dawn/native/AttachmentState.cpp +++ b/src/dawn/native/AttachmentState.cpp
@@ -141,7 +141,7 @@ if (colorAttachment.loadOp == wgpu::LoadOp::ExpandResolveTexture) { mExpandResolveInfo.attachmentsToExpandResolve.set(i); } - mExpandResolveInfo.resolveTargetsMask.set(i, colorAttachment.resolveTarget); + mExpandResolveInfo.resolveTargetsMask.set(i, colorAttachment.resolveTarget != nullptr); } // Gather the depth-stencil information.
diff --git a/src/dawn/native/BindGroup.cpp b/src/dawn/native/BindGroup.cpp index 831b699..82660d1 100644 --- a/src/dawn/native/BindGroup.cpp +++ b/src/dawn/native/BindGroup.cpp
@@ -500,7 +500,8 @@ // TODO(42240282): Store external textures in // BindGroupLayoutBase::BindingDataPointers::bindings so checking external textures can // be moved in the switch below. - if (layout->GetExternalTextureBindingExpansionMap().count(BindingNumber(entry.binding))) { + if (layout->GetExternalTextureBindingExpansionMap().count(BindingNumber(entry.binding)) != + 0u) { UnpackedPtr<BindGroupEntry> unpacked; DAWN_TRY_ASSIGN(unpacked, ValidateAndUnpack(&entry)); if (auto* externalTextureBindingEntry = unpacked.Get<ExternalTextureBindingEntry>()) {
diff --git a/src/dawn/native/BlitColorToColorWithDraw.cpp b/src/dawn/native/BlitColorToColorWithDraw.cpp index 69ebc30..627242c 100644 --- a/src/dawn/native/BlitColorToColorWithDraw.cpp +++ b/src/dawn/native/BlitColorToColorWithDraw.cpp
@@ -289,7 +289,7 @@ wgpu::TextureViewDimension::e2D); pipelineKey.attachmentsToExpandResolve.set(colorIdx); } - pipelineKey.resolveTargetsMask.set(colorIdx, colorAttachment.resolveTarget); + pipelineKey.resolveTargetsMask.set(colorIdx, colorAttachment.resolveTarget != nullptr); pipelineKey.colorTargetFormats[colorIdx] = format.format; pipelineKey.sampleCount = view->GetTexture()->GetSampleCount();
diff --git a/src/dawn/native/Texture.cpp b/src/dawn/native/Texture.cpp index e395ab4..7c8be3c 100644 --- a/src/dawn/native/Texture.cpp +++ b/src/dawn/native/Texture.cpp
@@ -1341,7 +1341,7 @@ } bool TextureBase::IsImplicitMSAARenderTextureViewSupported() const { - return (GetUsage() & wgpu::TextureUsage::TextureBinding) != 0; + return GetUsage() & wgpu::TextureUsage::TextureBinding; } void TextureBase::SetSharedResourceMemoryContentsForTesting( @@ -1366,7 +1366,7 @@ // Do not emit a non-zero size for textures that wrap external shared texture memory, or // textures used as transient (memoryless) attachments. if (GetSharedResourceMemoryContents() != nullptr || - (GetInternalUsage() & wgpu::TextureUsage::TransientAttachment) != 0) { + (GetInternalUsage() & wgpu::TextureUsage::TransientAttachment)) { return 0; } uint64_t byteSize = 0;
diff --git a/src/dawn/native/X11Functions.cpp b/src/dawn/native/X11Functions.cpp index d5dd14e..e6bad07 100644 --- a/src/dawn/native/X11Functions.cpp +++ b/src/dawn/native/X11Functions.cpp
@@ -69,7 +69,7 @@ } // Make all X11 calls synchronous so that the error handler is called immediately. - sDebug->x.xSynchronize(display, true); + sDebug->x.xSynchronize(display, 1); } static int HandleError(Display* d, XErrorEvent* e) {
diff --git a/src/dawn/native/null/DeviceNull.cpp b/src/dawn/native/null/DeviceNull.cpp index 2018495..3b189b9 100644 --- a/src/dawn/native/null/DeviceNull.cpp +++ b/src/dawn/native/null/DeviceNull.cpp
@@ -373,7 +373,7 @@ bool Buffer::IsCPUWritableAtCreation() const { // Only return true for mappable buffers so we can test cases that need / don't need a // staging buffer. - return (GetInternalUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) != 0; + return GetInternalUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite); } MaybeError Buffer::MapAtCreationImpl() {
diff --git a/src/dawn/native/opengl/ContextEGL.cpp b/src/dawn/native/opengl/ContextEGL.cpp index 2a45ff1..fd6c3bf 100644 --- a/src/dawn/native/opengl/ContextEGL.cpp +++ b/src/dawn/native/opengl/ContextEGL.cpp
@@ -215,7 +215,8 @@ void ContextEGL::MakeCurrent() { EGLBoolean success = mDisplay->egl.MakeCurrent(mDisplay->GetDisplay(), mCurrentSurface, mCurrentSurface, mContext); - IgnoreErrors(CheckEGL(mDisplay->egl, success == EGL_TRUE, "eglMakeCurrent")); + IgnoreErrors( + CheckEGL(mDisplay->egl, static_cast<EGLBoolean>(success == EGL_TRUE), "eglMakeCurrent")); } // ScopedMakeSurfaceCurrent
diff --git a/src/dawn/native/opengl/TextureGL.cpp b/src/dawn/native/opengl/TextureGL.cpp index e28d21a..b1f618c 100644 --- a/src/dawn/native/opengl/TextureGL.cpp +++ b/src/dawn/native/opengl/TextureGL.cpp
@@ -89,7 +89,7 @@ wgpu::TextureUsage::StorageBinding | wgpu::TextureUsage::TextureBinding; constexpr wgpu::TextureUsage kUsageNeedsView = kShaderUsageNeedsView | wgpu::TextureUsage::RenderAttachment; - if ((texture->GetInternalUsage() & kUsageNeedsView) == 0) { + if (!(texture->GetInternalUsage() & kUsageNeedsView)) { return false; } @@ -102,7 +102,7 @@ // Reinterpretation not required. Now, we only need a new view if the view dimension or // set of subresources for the shader is different from the base texture. - if ((texture->GetInternalUsage() & kShaderUsageNeedsView) == 0) { + if (!(texture->GetInternalUsage() & kShaderUsageNeedsView)) { return false; } @@ -116,7 +116,7 @@ } if (ToBackend(texture)->GetGLFormat().format == GL_DEPTH_STENCIL && - (texture->GetUsage() & wgpu::TextureUsage::TextureBinding) != 0 && + (texture->GetUsage() & wgpu::TextureUsage::TextureBinding) && textureViewDescriptor->aspect == wgpu::TextureAspect::StencilOnly) { // We need a separate view for one of the depth or stencil planes // because each glTextureView needs it's own handle to set
diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp index c791872..67c2ed5 100644 --- a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp +++ b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
@@ -112,7 +112,7 @@ VkFormatProperties properties; mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(mVkPhysicalDevice, format, &properties); - return properties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; + return (properties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0; } MaybeError PhysicalDevice::InitializeImpl() {
diff --git a/src/dawn/native/vulkan/RenderPipelineVk.cpp b/src/dawn/native/vulkan/RenderPipelineVk.cpp index d374ec6..3892ff8 100644 --- a/src/dawn/native/vulkan/RenderPipelineVk.cpp +++ b/src/dawn/native/vulkan/RenderPipelineVk.cpp
@@ -419,7 +419,8 @@ inputAssembly.pNext = nullptr; inputAssembly.flags = 0; inputAssembly.topology = VulkanPrimitiveTopology(GetPrimitiveTopology()); - inputAssembly.primitiveRestartEnable = ShouldEnablePrimitiveRestart(GetPrimitiveTopology()); + inputAssembly.primitiveRestartEnable = + ShouldEnablePrimitiveRestart(GetPrimitiveTopology()) ? VK_TRUE : VK_FALSE; // A placeholder viewport/scissor info. The validation layers force use to provide at least // one scissor and one viewport here, even if we choose to make them dynamic. @@ -448,12 +449,12 @@ rasterization.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterization.pNext = nullptr; rasterization.flags = 0; - rasterization.depthClampEnable = HasUnclippedDepth(); + rasterization.depthClampEnable = HasUnclippedDepth() ? VK_TRUE : VK_FALSE; rasterization.rasterizerDiscardEnable = VK_FALSE; rasterization.polygonMode = VK_POLYGON_MODE_FILL; rasterization.cullMode = VulkanCullMode(GetCullMode()); rasterization.frontFace = VulkanFrontFace(GetFrontFace()); - rasterization.depthBiasEnable = IsDepthBiasEnabled(); + rasterization.depthBiasEnable = IsDepthBiasEnabled() ? VK_TRUE : VK_FALSE; rasterization.depthBiasConstantFactor = GetDepthBias(); rasterization.depthBiasClamp = GetDepthBiasClamp(); rasterization.depthBiasSlopeFactor = GetDepthBiasSlopeScale(); @@ -472,7 +473,7 @@ DAWN_ASSERT(multisample.rasterizationSamples <= 32); VkSampleMask sampleMask = GetSampleMask(); multisample.pSampleMask = &sampleMask; - multisample.alphaToCoverageEnable = IsAlphaToCoverageEnabled(); + multisample.alphaToCoverageEnable = IsAlphaToCoverageEnabled() ? VK_TRUE : VK_FALSE; multisample.alphaToOneEnable = VK_FALSE; VkPipelineDepthStencilStateCreateInfo depthStencilState = ComputeDepthStencilDesc(); @@ -697,7 +698,7 @@ depthStencilState.depthWriteEnable = descriptor->depthWriteEnabled == wgpu::OptionalBool::True ? VK_TRUE : VK_FALSE; depthStencilState.depthCompareOp = ToVulkanCompareOp(descriptor->depthCompare); - depthStencilState.depthBoundsTestEnable = false; + depthStencilState.depthBoundsTestEnable = VK_FALSE; depthStencilState.minDepthBounds = 0.0f; depthStencilState.maxDepthBounds = 1.0f;
diff --git a/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp b/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp index 4c9fb76..712e0fe 100644 --- a/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp +++ b/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp
@@ -380,9 +380,9 @@ // allocation (note: this is a more important property than that of // device local memory and hence is checked first). bool currentLazilyAllocated = - info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT; - bool bestLazilyAllocated = - info.memoryTypes[bestType].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT; + (info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) != 0u; + bool bestLazilyAllocated = (info.memoryTypes[bestType].propertyFlags & + VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) != 0u; if ((kind == MemoryKind::LazilyAllocated) && (currentLazilyAllocated != bestLazilyAllocated)) { if (currentLazilyAllocated) { @@ -394,9 +394,9 @@ // For non-mappable, non-lazily-allocated resources, favor device local // memory. bool currentDeviceLocal = - info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + (info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0u; bool bestDeviceLocal = - info.memoryTypes[bestType].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + (info.memoryTypes[bestType].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0u; if (!mappable && (currentDeviceLocal != bestDeviceLocal)) { if (currentDeviceLocal) { bestType = static_cast<int>(i); @@ -407,9 +407,9 @@ // Cached memory is optimal for read-only access from CPU as host memory accesses to // uncached memory are slower than to cached memory. bool currentHostCached = - info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT; + (info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) != 0u; bool bestHostCached = - info.memoryTypes[bestType].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT; + (info.memoryTypes[bestType].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) != 0u; if ((kind & MemoryKind::ReadMappable) && currentHostCached != bestHostCached) { if (currentHostCached) { bestType = static_cast<int>(i);
diff --git a/src/dawn/native/vulkan/ShaderModuleVk.cpp b/src/dawn/native/vulkan/ShaderModuleVk.cpp index b482f2b..2990a52 100644 --- a/src/dawn/native/vulkan/ShaderModuleVk.cpp +++ b/src/dawn/native/vulkan/ShaderModuleVk.cpp
@@ -487,7 +487,7 @@ VkShaderModuleCreateInfo createInfo; createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; createInfo.pNext = nullptr; - createInfo.flags = 0; + createInfo.flags = 0u; createInfo.codeSize = compilation->spirv.size() * sizeof(uint32_t); createInfo.pCode = compilation->spirv.data();
diff --git a/src/dawn/native/vulkan/SwapChainVk.cpp b/src/dawn/native/vulkan/SwapChainVk.cpp index ed487ef..504d4c1 100644 --- a/src/dawn/native/vulkan/SwapChainVk.cpp +++ b/src/dawn/native/vulkan/SwapChainVk.cpp
@@ -191,7 +191,7 @@ createInfo.preTransform = mConfig.transform; createInfo.compositeAlpha = mConfig.alphaMode; createInfo.presentMode = mConfig.presentMode; - createInfo.clipped = false; + createInfo.clipped = VK_FALSE; createInfo.oldSwapchain = previousVkSwapChain; DAWN_TRY(CheckVkSuccess(
diff --git a/src/dawn/native/vulkan/TextureVk.cpp b/src/dawn/native/vulkan/TextureVk.cpp index 098423a..7d958dc 100644 --- a/src/dawn/native/vulkan/TextureVk.cpp +++ b/src/dawn/native/vulkan/TextureVk.cpp
@@ -791,7 +791,7 @@ DAWN_UNREACHABLE(); } - return properties.sampleCounts & imageCreateInfo.samples; + return (properties.sampleCounts & imageCreateInfo.samples) != 0u; } Texture::Texture(Device* device, const UnpackedPtr<TextureDescriptor>& descriptor)
diff --git a/src/dawn/native/vulkan/external_memory/MemoryServiceImplementation.cpp b/src/dawn/native/vulkan/external_memory/MemoryServiceImplementation.cpp index 140194b..3afc31b 100644 --- a/src/dawn/native/vulkan/external_memory/MemoryServiceImplementation.cpp +++ b/src/dawn/native/vulkan/external_memory/MemoryServiceImplementation.cpp
@@ -65,7 +65,7 @@ // The Vulkan spec requires that prefersDA is set if requiresDA is, so we can just check // for prefersDA. - return dedicatedRequirements.prefersDedicatedAllocation; + return dedicatedRequirements.prefersDedicatedAllocation != 0u; } DAWN_UNREACHABLE(); }
diff --git a/src/dawn/native/vulkan/external_memory/MemoryServiceImplementationDmaBuf.cpp b/src/dawn/native/vulkan/external_memory/MemoryServiceImplementationDmaBuf.cpp index d02ebe3..b64e18c 100644 --- a/src/dawn/native/vulkan/external_memory/MemoryServiceImplementationDmaBuf.cpp +++ b/src/dawn/native/vulkan/external_memory/MemoryServiceImplementationDmaBuf.cpp
@@ -122,7 +122,7 @@ if (IsMultiPlanarVkFormat(format)) { VkDrmFormatModifierPropertiesEXT props; return (GetFormatModifierProps(fn, vkPhysicalDevice, format, modifier, &props) && - (props.drmFormatModifierTilingFeatures & VK_FORMAT_FEATURE_DISJOINT_BIT)); + ((props.drmFormatModifierTilingFeatures & VK_FORMAT_FEATURE_DISJOINT_BIT) != 0u)); } return false; } @@ -236,7 +236,7 @@ } VkExternalMemoryFeatureFlags featureFlags = externalImageFormatProps.externalMemoryProperties.externalMemoryFeatures; - return featureFlags & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT; + return (featureFlags & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) != 0u; } ResultOrError<MemoryImportParams> GetMemoryImportParams(
diff --git a/src/dawn/node/binding/GPU.cpp b/src/dawn/node/binding/GPU.cpp index a83469d..86f38a1 100644 --- a/src/dawn/node/binding/GPU.cpp +++ b/src/dawn/node/binding/GPU.cpp
@@ -301,7 +301,7 @@ if (!interop::Converter<interop::WGSLLanguageFeatureName>::FromString(name, feature)) { return false; } - return features_.count(feature); + return features_.count(feature) != 0u; } std::vector<std::string> keys(Napi::Env env) { std::vector<std::string> out;
diff --git a/src/dawn/node/binding/GPUSupportedFeatures.cpp b/src/dawn/node/binding/GPUSupportedFeatures.cpp index 3ed9e21..941218a 100644 --- a/src/dawn/node/binding/GPUSupportedFeatures.cpp +++ b/src/dawn/node/binding/GPUSupportedFeatures.cpp
@@ -57,7 +57,7 @@ return false; } - return enabled_.count(feature); + return enabled_.count(feature) != 0u; } std::vector<std::string> GPUSupportedFeatures::keys(Napi::Env) {
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp index f8fa35d..fc8343d 100644 --- a/src/dawn/tests/DawnTest.cpp +++ b/src/dawn/tests/DawnTest.cpp
@@ -895,16 +895,16 @@ } bool DawnTestBase::IsANGLE() const { - return !mParam.adapterProperties.name.find("ANGLE"); + return mParam.adapterProperties.name.find("ANGLE") == 0u; } bool DawnTestBase::IsANGLESwiftShader() const { - return !mParam.adapterProperties.name.find("ANGLE") && + return (mParam.adapterProperties.name.find("ANGLE") == 0u) && (mParam.adapterProperties.name.find("SwiftShader") != std::string::npos); } bool DawnTestBase::IsANGLED3D11() const { - return !mParam.adapterProperties.name.find("ANGLE") && + return (mParam.adapterProperties.name.find("ANGLE") == 0u) && (mParam.adapterProperties.name.find("Direct3D11") != std::string::npos); } @@ -1250,9 +1250,9 @@ WGPUInstanceDescriptor instanceDesc = {}; WGPUDawnWireWGSLControl wgslControl; wgslControl.chain.sType = WGPUSType_DawnWireWGSLControl; - wgslControl.enableExperimental = true; - wgslControl.enableTesting = true; - wgslControl.enableUnsafe = true; + wgslControl.enableExperimental = 1u; + wgslControl.enableTesting = 1u; + wgslControl.enableUnsafe = 1u; instanceDesc.nextInChain = &wgslControl.chain; wgslControl.chain.next = nullptr; instance = mWireHelper->RegisterInstance(gTestEnv->GetInstance()->Get(), &instanceDesc);
diff --git a/src/dawn/tests/unittests/validation/OverridableConstantsValidationTests.cpp b/src/dawn/tests/unittests/validation/OverridableConstantsValidationTests.cpp index 86399a6..d6b1e94 100644 --- a/src/dawn/tests/unittests/validation/OverridableConstantsValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/OverridableConstantsValidationTests.cpp
@@ -206,7 +206,7 @@ { // Error: uninitialized constants exist std::vector<wgpu::ConstantEntry> constants{ - {nullptr, "c0", false}, + {nullptr, "c0", 0.0}, {nullptr, "c2", 1}, // c5 is missing {nullptr, "c8", 1}, @@ -217,16 +217,16 @@ { // Valid: all constants initialized std::vector<wgpu::ConstantEntry> constants{ - {nullptr, "c0", false}, {nullptr, "c2", 1}, {nullptr, "c5", 1}, - {nullptr, "c8", 1}, {nullptr, "c11", 1}, + {nullptr, "c0", 0.0}, {nullptr, "c2", 1}, {nullptr, "c5", 1}, + {nullptr, "c8", 1}, {nullptr, "c11", 1}, }; TestCreatePipeline(constants); } { // Error: duplicate initializations std::vector<wgpu::ConstantEntry> constants{ - {nullptr, "c0", false}, {nullptr, "c2", 1}, {nullptr, "c5", 1}, - {nullptr, "c8", 1}, {nullptr, "c11", 1}, {nullptr, "c2", 2}, + {nullptr, "c0", 0.0}, {nullptr, "c2", 1}, {nullptr, "c5", 1}, + {nullptr, "c8", 1}, {nullptr, "c11", 1}, {nullptr, "c2", 2}, }; ASSERT_DEVICE_ERROR(TestCreatePipeline(constants)); }
diff --git a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp index a6931e5..2f9e66a 100644 --- a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp +++ b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp
@@ -1602,7 +1602,7 @@ // Skipped for multiplanar formats because those must be initialized on import. // We also need render attachment usage to initially populate the texture. if (utils::IsMultiPlanarFormat(properties.format) || - (properties.usage & wgpu::TextureUsage::RenderAttachment) == 0) { + !(properties.usage & wgpu::TextureUsage::RenderAttachment)) { continue; }
diff --git a/src/dawn/wire/client/Buffer.cpp b/src/dawn/wire/client/Buffer.cpp index e33afae..fcba11bd 100644 --- a/src/dawn/wire/client/Buffer.cpp +++ b/src/dawn/wire/client/Buffer.cpp
@@ -51,7 +51,7 @@ WGPUBufferDescriptor errorBufferDescriptor = *descriptor; WGPUDawnBufferDescriptorErrorInfoFromWireClient errorInfo = {}; errorInfo.chain.sType = WGPUSType_DawnBufferDescriptorErrorInfoFromWireClient; - errorInfo.outOfMemory = true; + errorInfo.outOfMemory = static_cast<WGPUBool>(true); errorBufferDescriptor.nextInChain = &errorInfo.chain; return device->CreateErrorBuffer(&errorBufferDescriptor); } @@ -195,7 +195,7 @@ case WGPUSType_DawnFakeBufferOOMForTesting: { auto oomForTesting = reinterpret_cast<const WGPUDawnFakeBufferOOMForTesting*>(chain); - fakeOOMAtWireClientMap = oomForTesting->fakeOOMAtWireClientMap; + fakeOOMAtWireClientMap = (oomForTesting->fakeOOMAtWireClientMap != 0u); } break; default: break; @@ -204,7 +204,7 @@ bool mappable = (descriptor->usage & (WGPUBufferUsage_MapRead | WGPUBufferUsage_MapWrite)) != 0 || - descriptor->mappedAtCreation; + wgpu::Bool(descriptor->mappedAtCreation); if (mappable && (descriptor->size >= std::numeric_limits<size_t>::max() || fakeOOMAtWireClientMap)) { return ReturnOOMAtClient(device, descriptor); @@ -323,7 +323,7 @@ mUsage(static_cast<WGPUBufferUsage>(descriptor->usage)), // This flag is for the write handle created by mappedAtCreation // instead of MapWrite usage. We don't have such a case for read handle. - mDestructWriteHandleOnUnmap(descriptor->mappedAtCreation && + mDestructWriteHandleOnUnmap(wgpu::Bool(descriptor->mappedAtCreation) && ((descriptor->usage & WGPUBufferUsage_MapWrite) == 0)), mDevice(device) {}
diff --git a/src/dawn/wire/client/Instance.cpp b/src/dawn/wire/client/Instance.cpp index ea307aa..c8d79c3 100644 --- a/src/dawn/wire/client/Instance.cpp +++ b/src/dawn/wire/client/Instance.cpp
@@ -250,10 +250,10 @@ break; case tint::wgsl::FeatureStatus::kUnsafeExperimental: - enable = wgslControl->enableUnsafe; + enable = wgpu::Bool(wgslControl->enableUnsafe); break; case tint::wgsl::FeatureStatus::kExperimental: - enable = wgslControl->enableExperimental; + enable = wgpu::Bool(wgslControl->enableExperimental); break; case tint::wgsl::FeatureStatus::kShippedWithKillswitch: @@ -319,7 +319,7 @@ return WGPUStatus_Error; } - capabilities->timedWaitAnyEnable = false; + capabilities->timedWaitAnyEnable = static_cast<WGPUBool>(0); capabilities->timedWaitAnyMaxCount = dawn::kTimedWaitAnyMaxCountDefault; return WGPUStatus_Success; }
diff --git a/src/dawn/wire/server/ServerBuffer.cpp b/src/dawn/wire/server/ServerBuffer.cpp index 2178a6a..e7c5e8d 100644 --- a/src/dawn/wire/server/ServerBuffer.cpp +++ b/src/dawn/wire/server/ServerBuffer.cpp
@@ -123,12 +123,13 @@ WIRE_TRY(Objects<WGPUBuffer>().Allocate(&buffer, bufferHandle)); buffer->handle = mProcs.deviceCreateBuffer(device->handle, descriptor); buffer->usage = descriptor->usage; - buffer->mappedAtCreation = descriptor->mappedAtCreation; + buffer->mappedAtCreation = (descriptor->mappedAtCreation != 0u); // isReadMode and isWriteMode could be true at the same time if usage contains // WGPUBufferUsage_MapRead and buffer is mappedAtCreation - bool isReadMode = descriptor->usage & WGPUBufferUsage_MapRead; - bool isWriteMode = descriptor->usage & WGPUBufferUsage_MapWrite || descriptor->mappedAtCreation; + bool isReadMode = (descriptor->usage & WGPUBufferUsage_MapRead) != 0u; + bool isWriteMode = ((descriptor->usage & WGPUBufferUsage_MapWrite) != 0u) || + (descriptor->mappedAtCreation != 0u); // This is the size of data deserialized from the command stream to create the read/write // handle, which must be CPU-addressable. @@ -239,7 +240,7 @@ return; } - bool isRead = data->mode & WGPUMapMode_Read; + bool isRead = (data->mode & WGPUMapMode_Read) != 0u; bool isSuccess = status == WGPUMapAsyncStatus_Success; ReturnBufferMapAsyncCallbackCmd cmd = {};
diff --git a/src/tint/cmd/tint/main.cc b/src/tint/cmd/tint/main.cc index b4a0566..5d2dc94 100644 --- a/src/tint/cmd/tint/main.cc +++ b/src/tint/cmd/tint/main.cc
@@ -785,7 +785,7 @@ auto res = ProcessASTTransforms(options, inspector, src_program, cfg); if (res != tint::Success) { std::cerr << res.Failure() << "\n"; - return 1; + return true; } // Convert the AST program to an IR module. @@ -960,7 +960,7 @@ auto transform_res = ProcessASTTransforms(options, inspector, src_program, cfg); if (transform_res != tint::Success) { std::cerr << transform_res.Failure() << "\n"; - return 1; + return true; } // Convert the AST program to an IR module. @@ -1108,7 +1108,7 @@ auto res = ProcessASTTransforms(options, inspector, src_program, cfg); if (res != tint::Success) { std::cerr << res.Failure() << "\n"; - return 1; + return true; } const bool for_fxc = options.format == Format::kHlslFxc; @@ -1278,7 +1278,7 @@ auto res = ProcessASTTransforms(options, inspector, src_program, cfg); if (res != tint::Success) { std::cerr << res.Failure() << "\n"; - return 1; + return true; } tint::glsl::writer::Options gen_options; @@ -1486,7 +1486,7 @@ if (options.dump_ir || options.format == Format::kIr) { auto res = DumpIR(info.program, options); if (options.format == Format::kIr) { - return res; + return static_cast<int>(res); } }
diff --git a/src/tint/lang/core/intrinsic/table.cc b/src/tint/lang/core/intrinsic/table.cc index c6f596f..f9017dd 100644 --- a/src/tint/lang/core/intrinsic/table.cc +++ b/src/tint/lang/core/intrinsic/table.cc
@@ -541,9 +541,9 @@ bool matched = false; if (i < template_args.Length()) { auto* matcher_indices = context.data[tmpl.matcher_indices]; - matched = !matcher_indices || - context.Match(templates, overload, matcher_indices, earliest_eval_stage) - .Type(template_args[i]); + matched = (matcher_indices == nullptr) || + (context.Match(templates, overload, matcher_indices, earliest_eval_stage) + .Type(template_args[i]) != nullptr); } if (i > 0) { @@ -567,8 +567,8 @@ bool matched = false; if (i < args.Length()) { - matched = context.Match(templates, overload, matcher_indices, earliest_eval_stage) - .Type(args[i]); + matched = (context.Match(templates, overload, matcher_indices, earliest_eval_stage) + .Type(args[i]) != nullptr); } all_params_match = all_params_match && matched; @@ -625,8 +625,8 @@ if (tmpl.kind == TemplateInfo::Kind::kType) { if (auto* ty = templates.Type(i)) { matched = - context.Match(templates, overload, matcher_indices, earliest_eval_stage) - .Type(ty); + (context.Match(templates, overload, matcher_indices, earliest_eval_stage) + .Type(ty) != nullptr); } } else { matched = context.Match(templates, overload, matcher_indices, earliest_eval_stage)
diff --git a/src/tint/lang/core/ir/transform/std140.cc b/src/tint/lang/core/ir/transform/std140.cc index bdd89cb..c1c07f2 100644 --- a/src/tint/lang/core/ir/transform/std140.cc +++ b/src/tint/lang/core/ir/transform/std140.cc
@@ -135,7 +135,7 @@ // // Due to a bug on Qualcomm devices, we also do this when the *size* of the column vector is // not a multiple of 16 bytes (e.g. matCx3 types). See crbug.com/tint/2074. - return mat->ColumnType()->Size() & 15; + return (mat->ColumnType()->Size() & 0xF) != 0; } /// Rewrite a type if necessary, decomposing contained matrices.
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc index f1eb822..c1f043c 100644 --- a/src/tint/lang/core/ir/validator.cc +++ b/src/tint/lang/core/ir/validator.cc
@@ -2053,7 +2053,8 @@ if (!IsValidFunctionParamType(param->Type())) { auto struct_ty = param->Type()->As<core::type::Struct>(); if (!capabilities_.Contains(Capability::kAllowPointersAndHandlesInStructures) || - !struct_ty || struct_ty->Members().Any([](const core::type::StructMember* m) { + (struct_ty == nullptr) || + struct_ty->Members().Any([](const core::type::StructMember* m) { return !IsValidFunctionParamType(m->Type()); })) { AddError(param) << "function parameter type, " << NameOf(param->Type()) @@ -2470,7 +2471,7 @@ } } - if (!o->OverrideId().has_value() && !o->Initializer()) { + if (!o->OverrideId().has_value() && (o->Initializer() == nullptr)) { AddError(o) << "must have an id or an initializer"; return; } @@ -3095,7 +3096,7 @@ bool ok = true; if (obj_view) { // Pointer source always means pointer result. - ok = want_view && ty == want_view->StoreType(); + ok = (want_view != nullptr) && ty == want_view->StoreType(); if (ok) { // Also check that the address space and access modes match. ok = obj_view->Is<core::type::Pointer>() == want_view->Is<core::type::Pointer>() &&
diff --git a/src/tint/lang/hlsl/validate/validate.cc b/src/tint/lang/hlsl/validate/validate.cc index 696b1a4..1b734a7 100644 --- a/src/tint/lang/hlsl/validate/validate.cc +++ b/src/tint/lang/hlsl/validate/validate.cc
@@ -224,7 +224,7 @@ CHECK_HR(hr, "Disassemble call failed"); CComPtr<IDxcBlobEncoding> disassembly; - if (dis_result && dis_result->HasOutput(DXC_OUT_DISASSEMBLY) && + if ((dis_result != nullptr) && dis_result->HasOutput(DXC_OUT_DISASSEMBLY) && SUCCEEDED( dis_result->GetOutput(DXC_OUT_DISASSEMBLY, IID_PPV_ARGS(&disassembly), nullptr))) { result.output = static_cast<char*>(disassembly->GetBufferPointer());
diff --git a/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.cc b/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.cc index 41a9c59..7059698 100644 --- a/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.cc +++ b/src/tint/lang/hlsl/writer/ast_raise/decompose_memory_access.cc
@@ -324,7 +324,7 @@ sem::GlobalVariable const* var = nullptr; // Storage or uniform buffer variable Offset const* offset = nullptr; // The byte offset on var core::type::Type const* type = nullptr; // The type of the access - explicit operator bool() const { return var; } // Returns true if valid + explicit operator bool() const { return var != nullptr; } // Returns true if valid }; /// Store describes a single storage or uniform buffer write
diff --git a/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc index 24c718f..161dad2 100644 --- a/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc +++ b/src/tint/lang/hlsl/writer/ast_raise/num_workgroups_from_uniform.cc
@@ -193,7 +193,7 @@ continue; } - if (to_replace.count({ident->identifier->symbol, accessor->member->symbol})) { + if (to_replace.count({ident->identifier->symbol, accessor->member->symbol}) != 0u) { ctx.Replace(accessor, b.MemberAccessor(get_ubo()->name->symbol, kNumWorkgroupsMemberName)); }
diff --git a/src/tint/lang/spirv/reader/ast_parser/ast_parser.cc b/src/tint/lang/spirv/reader/ast_parser/ast_parser.cc index 509a914..44b66c4 100644 --- a/src/tint/lang/spirv/reader/ast_parser/ast_parser.cc +++ b/src/tint/lang/spirv/reader/ast_parser/ast_parser.cc
@@ -93,7 +93,7 @@ private: void Visit(const spvtools::opt::Function& f) { - if (visited_.count(&f)) { + if (visited_.count(&f) != 0u) { return; } visited_.insert(&f);
diff --git a/src/tint/lang/spirv/reader/ast_parser/function.cc b/src/tint/lang/spirv/reader/ast_parser/function.cc index c77fc4d..ea3d549 100644 --- a/src/tint/lang/spirv/reader/ast_parser/function.cc +++ b/src/tint/lang/spirv/reader/ast_parser/function.cc
@@ -1482,8 +1482,8 @@ TINT_ASSERT(obj.type_id() != 0u); auto* spirv_type = type_mgr_->GetType(obj.type_id()); TINT_ASSERT(spirv_type); - return spirv_type->AsImage() || spirv_type->AsSampler() || - (spirv_type->AsPointer() && + return (spirv_type->AsImage() != nullptr) || (spirv_type->AsSampler() != nullptr) || + ((spirv_type->AsPointer() != nullptr) && (static_cast<spv::StorageClass>(spirv_type->AsPointer()->storage_class()) == spv::StorageClass::UniformConstant)); }
diff --git a/src/tint/lang/spirv/reader/parser/parser.cc b/src/tint/lang/spirv/reader/parser/parser.cc index f0b1eae..009b05e 100644 --- a/src/tint/lang/spirv/reader/parser/parser.cc +++ b/src/tint/lang/spirv/reader/parser/parser.cc
@@ -1595,7 +1595,7 @@ // in the case of a SPIR-V loop where the header_id and continue_id // are the same. We'll be emitting into the IR body, but branch to // the header because that's also the continuing in SPIR-V. - if (current_blocks_.count(loop->Continuing())) { + if (current_blocks_.count(loop->Continuing()) != 0u) { if (true_id == merge_id && false_is_header) { EmitWithoutResult(b_.BreakIf(loop, cond)); return true;
diff --git a/src/tint/lang/spirv/writer/printer/printer.cc b/src/tint/lang/spirv/writer/printer/printer.cc index a6ee023..f429ef7 100644 --- a/src/tint/lang/spirv/writer/printer/printer.cc +++ b/src/tint/lang/spirv/writer/printer/printer.cc
@@ -1013,11 +1013,13 @@ uint32_t false_label = merge_label; if (true_block->Length() > 1 || !i->Results().IsEmpty() || - (true_block->Terminator() && !true_block->Terminator()->Is<core::ir::ExitIf>())) { + ((true_block->Terminator() != nullptr) && + !true_block->Terminator()->Is<core::ir::ExitIf>())) { true_label = Label(true_block); } if (false_block->Length() > 1 || !i->Results().IsEmpty() || - (false_block->Terminator() && !false_block->Terminator()->Is<core::ir::ExitIf>())) { + ((false_block->Terminator() != nullptr) && + !false_block->Terminator()->Is<core::ir::ExitIf>())) { false_label = Label(false_block); }
diff --git a/src/tint/lang/spirv/writer/raise/expand_implicit_splats.cc b/src/tint/lang/spirv/writer/raise/expand_implicit_splats.cc index 4f8642d..2ec5a5f 100644 --- a/src/tint/lang/spirv/writer/raise/expand_implicit_splats.cc +++ b/src/tint/lang/spirv/writer/raise/expand_implicit_splats.cc
@@ -57,7 +57,7 @@ // A vector constructor with a single scalar argument needs to be modified to // replicate the argument N times. auto* vec = construct->Result()->Type()->As<core::type::Vector>(); - if (vec && // + if ((vec != nullptr) && // construct->Args().Length() == 1 && construct->Args()[0]->Type()->Is<core::type::Scalar>()) { for (uint32_t i = 1; i < vec->Width(); i++) {
diff --git a/src/tint/lang/wgsl/inspector/inspector.cc b/src/tint/lang/wgsl/inspector/inspector.cc index 44dddd2..81c9891 100644 --- a/src/tint/lang/wgsl/inspector/inspector.cc +++ b/src/tint/lang/wgsl/inspector/inspector.cc
@@ -237,7 +237,7 @@ TINT_UNREACHABLE(); } - override.is_initialized = global->Declaration()->initializer; + override.is_initialized = (global->Declaration()->initializer != nullptr); override.is_id_specified = ast::HasAttribute<ast::IdAttribute>(global->Declaration()->attributes); return override; @@ -635,7 +635,7 @@ auto declarations = sem.Module()->DependencyOrderedDeclarations(); for (auto rit = declarations.rbegin(); rit != declarations.rend(); rit++) { auto* fn = sem.Get<sem::Function>(*rit); - if (!fn || !fn->HasCallGraphEntryPoint(entry_point_symbol)) { + if ((fn == nullptr) || !fn->HasCallGraphEntryPoint(entry_point_symbol)) { continue; }
diff --git a/src/tint/lang/wgsl/reader/parser/expression_test.cc b/src/tint/lang/wgsl/reader/parser/expression_test.cc index 16d0ba0..3f751d0 100644 --- a/src/tint/lang/wgsl/reader/parser/expression_test.cc +++ b/src/tint/lang/wgsl/reader/parser/expression_test.cc
@@ -487,7 +487,7 @@ }; static bool ParsedAsTemplateArgumentList(BinaryOperatorInfo lhs_op, BinaryOperatorInfo rhs_op) { - return lhs_op.bit == kOpLt && rhs_op.bit & (kOpGt | kOpGe | kOpShr); + return lhs_op.bit == kOpLt && ((rhs_op.bit & (kOpGt | kOpGe | kOpShr)) != 0u); } static StringStream& operator<<(StringStream& o, const Case& c) { return o << "a " << c.lhs_op.symbol << " b " << c.rhs_op.symbol << " c "; @@ -498,7 +498,7 @@ for (auto& lhs_op : kBinaryOperators) { for (auto& rhs_op : kBinaryOperators) { if (!ParsedAsTemplateArgumentList(lhs_op, rhs_op)) { - bool should_parse = lhs_op.can_follow_without_paren & rhs_op.bit; + bool should_parse = (lhs_op.can_follow_without_paren & rhs_op.bit) != 0u; out.push_back({lhs_op, rhs_op, should_parse}); } }
diff --git a/src/tint/lang/wgsl/reader/parser/lexer.cc b/src/tint/lang/wgsl/reader/parser/lexer.cc index fce1388..41583b0 100644 --- a/src/tint/lang/wgsl/reader/parser/lexer.cc +++ b/src/tint/lang/wgsl/reader/parser/lexer.cc
@@ -253,10 +253,10 @@ } bool Lexer::is_digit(char ch) const { - return std::isdigit(static_cast<unsigned char>(ch)); + return std::isdigit(static_cast<unsigned char>(ch)) != 0; } bool Lexer::is_hex(char ch) const { - return std::isxdigit(static_cast<unsigned char>(ch)); + return std::isxdigit(static_cast<unsigned char>(ch)) != 0; } bool Lexer::matches(uint32_t pos, std::string_view sub_string) {
diff --git a/src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.cc b/src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.cc index 854b442..8047666 100644 --- a/src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.cc +++ b/src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.cc
@@ -194,7 +194,9 @@ diag::Diagnostic& AddError(const Source& source) { return diagnostics_.AddError(source); } - bool NeedTerminator() { return current_block_ && !current_block_->Terminator(); } + bool NeedTerminator() { + return (current_block_ != nullptr) && (current_block_->Terminator() == nullptr); + } void SetTerminator(core::ir::Terminator* terminator) { TINT_ASSERT(current_block_);
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc index d0b90f9..ae92315 100644 --- a/src/tint/lang/wgsl/resolver/resolver.cc +++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -1948,7 +1948,7 @@ bool Resolver::ShouldMaterializeArgument(const core::type::Type* parameter_ty) const { const auto* param_el_ty = parameter_ty->DeepestElement(); - return param_el_ty && !param_el_ty->Is<core::type::AbstractNumeric>(); + return (param_el_ty != nullptr) && !param_el_ty->Is<core::type::AbstractNumeric>(); } bool Resolver::Convert(const core::constant::Value*& c, @@ -2013,7 +2013,8 @@ const core::type::Type* storage_ty = object_ty->UnwrapRef(); if (memory_view) { if (memory_view->Is<core::type::Pointer>() && - !allowed_features_.features.count(wgsl::LanguageFeature::kPointerCompositeAccess)) { + (allowed_features_.features.count(wgsl::LanguageFeature::kPointerCompositeAccess) == + 0u)) { AddError(expr->source) << "pointer composite access requires the pointer_composite_access language " "feature, which is not allowed in the current environment"; @@ -3231,7 +3232,7 @@ return false; } } - return ident; + return ident != nullptr; } size_t Resolver::NestDepth(const core::type::Type* ty) const { @@ -3528,7 +3529,8 @@ const core::type::Type* storage_ty = object_ty->UnwrapRef(); if (memory_view) { if (memory_view->Is<core::type::Pointer>() && - !allowed_features_.features.count(wgsl::LanguageFeature::kPointerCompositeAccess)) { + (allowed_features_.features.count(wgsl::LanguageFeature::kPointerCompositeAccess) == + 0u)) { AddError(expr->source) << "pointer composite access requires the pointer_composite_access language " "feature, which is not allowed in the current environment";
diff --git a/src/tint/lang/wgsl/resolver/validator.cc b/src/tint/lang/wgsl/resolver/validator.cc index edd26f0..c63ea3a 100644 --- a/src/tint/lang/wgsl/resolver/validator.cc +++ b/src/tint/lang/wgsl/resolver/validator.cc
@@ -399,8 +399,8 @@ bool Validator::StorageTexture(const core::type::StorageTexture* t, const Source& source) const { switch (t->Access()) { case core::Access::kRead: - if (!allowed_features_.features.count( - wgsl::LanguageFeature::kReadonlyAndReadwriteStorageTextures)) { + if (allowed_features_.features.count( + wgsl::LanguageFeature::kReadonlyAndReadwriteStorageTextures) == 0u) { AddError(source) << "read-only storage textures require the " "readonly_and_readwrite_storage_textures language feature, " "which is not allowed in the current environment"; @@ -408,8 +408,8 @@ } break; case core::Access::kReadWrite: - if (!allowed_features_.features.count( - wgsl::LanguageFeature::kReadonlyAndReadwriteStorageTextures)) { + if (allowed_features_.features.count( + wgsl::LanguageFeature::kReadonlyAndReadwriteStorageTextures) == 0u) { AddError(source) << "read-write storage textures require the " "readonly_and_readwrite_storage_textures language feature, " "which is not allowed in the current environment"; @@ -684,8 +684,9 @@ // alignment requirement of the address space. auto* align_attr = ast::GetAttribute<ast::StructMemberAlignAttribute>(m->Declaration()->attributes); - if (align_attr && !enabled_extensions_.Contains( - wgsl::Extension::kChromiumInternalRelaxedUniformLayout)) { + if ((align_attr != nullptr) && + !enabled_extensions_.Contains( + wgsl::Extension::kChromiumInternalRelaxedUniformLayout)) { auto align = sem_.GetVal(align_attr->expr)->ConstantValue()->ValueAs<uint32_t>(); if (align % required_align != 0) { AddError(align_attr->expr->source) @@ -1149,7 +1150,7 @@ } auto* arr = type->As<sem::Array>(); if (!ignore_clip_distances_type_validation && - !(arr && arr->ElemType()->Is<core::type::F32>() && + !((arr != nullptr) && arr->ElemType()->Is<core::type::F32>() && arr->ConstantCount().has_value() && *arr->ConstantCount() <= kMaxClipDistancesSize)) { AddError(attr->source) @@ -1785,9 +1786,9 @@ } auto* expr = call->Declaration(); - bool is_call_stmt = - current_statement && Is<ast::CallStatement>(current_statement->Declaration(), - [&](auto* stmt) { return stmt->expr == expr; }); + bool is_call_stmt = (current_statement != nullptr) && + Is<ast::CallStatement>(current_statement->Declaration(), + [&](auto* stmt) { return stmt->expr == expr; }); if (is_call_stmt) { // Call target is annotated with @must_use, but was used as a call statement. Switch( @@ -2222,8 +2223,8 @@ } if (param_type->Is<core::type::Pointer>() && - !allowed_features_.features.count( - wgsl::LanguageFeature::kUnrestrictedPointerParameters)) { + (allowed_features_.features.count( + wgsl::LanguageFeature::kUnrestrictedPointerParameters) == 0u)) { // https://gpuweb.github.io/gpuweb/wgsl/#function-restriction // Each argument of pointer type to a user-defined function must have the same memory // view as its root identifier.
diff --git a/src/tint/utils/command/command_posix.cc b/src/tint/utils/command/command_posix.cc index f68becd..0d6302f 100644 --- a/src/tint/utils/command/command_posix.cc +++ b/src/tint/utils/command/command_posix.cc
@@ -121,7 +121,7 @@ if (stat(path.c_str(), &s) != 0) { return false; } - return s.st_mode & S_IXUSR; + return (s.st_mode & S_IXUSR) != 0u; } std::string GetCWD() {
diff --git a/src/tint/utils/text/string.h b/src/tint/utils/text/string.h index e000c79..6f3d5fd 100644 --- a/src/tint/utils/text/string.h +++ b/src/tint/utils/text/string.h
@@ -99,14 +99,14 @@ /// @param str the input string /// @param prefix the prefix string /// @returns true iff @p str has the prefix @p prefix -inline size_t HasPrefix(std::string_view str, std::string_view prefix) { +inline bool HasPrefix(std::string_view str, std::string_view prefix) { return str.length() >= prefix.length() && str.substr(0, prefix.length()) == prefix; } /// @param str the input string /// @param suffix the suffix string /// @returns true iff @p str has the suffix @p suffix -inline size_t HasSuffix(std::string_view str, std::string_view suffix) { +inline bool HasSuffix(std::string_view str, std::string_view suffix) { return str.length() >= suffix.length() && str.substr(str.length() - suffix.length()) == suffix; }