general: Silence -Wshadow{,-uncaptured-local} warnings

These occur in the latest commits in LLVM Clang.
This commit is contained in:
lat9nq 2023-07-18 19:31:35 -04:00
parent 3fded314f2
commit 71b3b2a2f0
12 changed files with 61 additions and 58 deletions

View File

@ -23,7 +23,7 @@ std::string DemangleSymbol(const std::string& mangled) {
SCOPE_EXIT({ std::free(demangled); }); SCOPE_EXIT({ std::free(demangled); });
if (is_itanium(mangled)) { if (is_itanium(mangled)) {
demangled = llvm::itaniumDemangle(mangled.c_str(), nullptr, nullptr, nullptr); demangled = llvm::itaniumDemangle(mangled.c_str());
} }
if (!demangled) { if (!demangled) {

View File

@ -30,8 +30,8 @@ DetachedTasks::~DetachedTasks() {
void DetachedTasks::AddTask(std::function<void()> task) { void DetachedTasks::AddTask(std::function<void()> task) {
std::unique_lock lock{instance->mutex}; std::unique_lock lock{instance->mutex};
++instance->count; ++instance->count;
std::thread([task{std::move(task)}]() { std::thread([task_{std::move(task)}]() {
task(); task_();
std::unique_lock thread_lock{instance->mutex}; std::unique_lock thread_lock{instance->mutex};
--instance->count; --instance->count;
std::notify_all_at_thread_exit(instance->cv, std::move(thread_lock)); std::notify_all_at_thread_exit(instance->cv, std::move(thread_lock));

View File

@ -302,12 +302,12 @@ Result KThread::InitializeServiceThread(Core::System& system, KThread* thread,
std::function<void()>&& func, s32 prio, s32 virt_core, std::function<void()>&& func, s32 prio, s32 virt_core,
KProcess* owner) { KProcess* owner) {
system.Kernel().GlobalSchedulerContext().AddThread(thread); system.Kernel().GlobalSchedulerContext().AddThread(thread);
std::function<void()> func2{[&system, func{std::move(func)}] { std::function<void()> func2{[&system, func_{std::move(func)}] {
// Similar to UserModeThreadStarter. // Similar to UserModeThreadStarter.
system.Kernel().CurrentScheduler()->OnThreadStart(); system.Kernel().CurrentScheduler()->OnThreadStart();
// Run the guest function. // Run the guest function.
func(); func_();
// Exit. // Exit.
Svc::ExitThread(system); Svc::ExitThread(system);

View File

@ -1089,15 +1089,15 @@ static std::jthread RunHostThreadFunc(KernelCore& kernel, KProcess* process,
KThread::Register(kernel, thread); KThread::Register(kernel, thread);
return std::jthread( return std::jthread(
[&kernel, thread, thread_name{std::move(thread_name)}, func{std::move(func)}] { [&kernel, thread, thread_name_{std::move(thread_name)}, func_{std::move(func)}] {
// Set the thread name. // Set the thread name.
Common::SetCurrentThreadName(thread_name.c_str()); Common::SetCurrentThreadName(thread_name_.c_str());
// Set the thread as current. // Set the thread as current.
kernel.RegisterHostThread(thread); kernel.RegisterHostThread(thread);
// Run the callback. // Run the callback.
func(); func_();
// Close the thread. // Close the thread.
// This will free the process if it is the last reference. // This will free the process if it is the last reference.

View File

@ -38,8 +38,8 @@ void RendererBase::RequestScreenshot(void* data, std::function<void(bool)> callb
LOG_ERROR(Render, "A screenshot is already requested or in progress, ignoring the request"); LOG_ERROR(Render, "A screenshot is already requested or in progress, ignoring the request");
return; return;
} }
auto async_callback{[callback = std::move(callback)](bool invert_y) { auto async_callback{[callback_ = std::move(callback)](bool invert_y) {
std::thread t{callback, invert_y}; std::thread t{callback_, invert_y};
t.detach(); t.detach();
}}; }};
renderer_settings.screenshot_bits = data; renderer_settings.screenshot_bits = data;

View File

@ -231,24 +231,25 @@ GraphicsPipeline::GraphicsPipeline(const Device& device, TextureCache& texture_c
} }
const bool in_parallel = thread_worker != nullptr; const bool in_parallel = thread_worker != nullptr;
const auto backend = device.GetShaderBackend(); const auto backend = device.GetShaderBackend();
auto func{[this, sources = std::move(sources), sources_spirv = std::move(sources_spirv), auto func{[this, sources_ = std::move(sources), sources_spirv_ = std::move(sources_spirv),
shader_notify, backend, in_parallel, shader_notify, backend, in_parallel,
force_context_flush](ShaderContext::Context*) mutable { force_context_flush](ShaderContext::Context*) mutable {
for (size_t stage = 0; stage < 5; ++stage) { for (size_t stage = 0; stage < 5; ++stage) {
switch (backend) { switch (backend) {
case Settings::ShaderBackend::GLSL: case Settings::ShaderBackend::GLSL:
if (!sources[stage].empty()) { if (!sources_[stage].empty()) {
source_programs[stage] = CreateProgram(sources[stage], Stage(stage)); source_programs[stage] = CreateProgram(sources_[stage], Stage(stage));
} }
break; break;
case Settings::ShaderBackend::GLASM: case Settings::ShaderBackend::GLASM:
if (!sources[stage].empty()) { if (!sources_[stage].empty()) {
assembly_programs[stage] = CompileProgram(sources[stage], AssemblyStage(stage)); assembly_programs[stage] =
CompileProgram(sources_[stage], AssemblyStage(stage));
} }
break; break;
case Settings::ShaderBackend::SPIRV: case Settings::ShaderBackend::SPIRV:
if (!sources_spirv[stage].empty()) { if (!sources_spirv_[stage].empty()) {
source_programs[stage] = CreateProgram(sources_spirv[stage], Stage(stage)); source_programs[stage] = CreateProgram(sources_spirv_[stage], Stage(stage));
} }
break; break;
} }

View File

@ -288,9 +288,9 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading,
const auto load_compute{[&](std::ifstream& file, FileEnvironment env) { const auto load_compute{[&](std::ifstream& file, FileEnvironment env) {
ComputePipelineKey key; ComputePipelineKey key;
file.read(reinterpret_cast<char*>(&key), sizeof(key)); file.read(reinterpret_cast<char*>(&key), sizeof(key));
queue_work([this, key, env = std::move(env), &state, &callback](Context* ctx) mutable { queue_work([this, key, env_ = std::move(env), &state, &callback](Context* ctx) mutable {
ctx->pools.ReleaseContents(); ctx->pools.ReleaseContents();
auto pipeline{CreateComputePipeline(ctx->pools, key, env, true)}; auto pipeline{CreateComputePipeline(ctx->pools, key, env_, true)};
std::scoped_lock lock{state.mutex}; std::scoped_lock lock{state.mutex};
if (pipeline) { if (pipeline) {
compute_cache.emplace(key, std::move(pipeline)); compute_cache.emplace(key, std::move(pipeline));
@ -305,9 +305,9 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading,
const auto load_graphics{[&](std::ifstream& file, std::vector<FileEnvironment> envs) { const auto load_graphics{[&](std::ifstream& file, std::vector<FileEnvironment> envs) {
GraphicsPipelineKey key; GraphicsPipelineKey key;
file.read(reinterpret_cast<char*>(&key), sizeof(key)); file.read(reinterpret_cast<char*>(&key), sizeof(key));
queue_work([this, key, envs = std::move(envs), &state, &callback](Context* ctx) mutable { queue_work([this, key, envs_ = std::move(envs), &state, &callback](Context* ctx) mutable {
boost::container::static_vector<Shader::Environment*, 5> env_ptrs; boost::container::static_vector<Shader::Environment*, 5> env_ptrs;
for (auto& env : envs) { for (auto& env : envs_) {
env_ptrs.push_back(&env); env_ptrs.push_back(&env);
} }
ctx->pools.ReleaseContents(); ctx->pools.ReleaseContents();

View File

@ -80,8 +80,8 @@ Buffer::Buffer(BufferCacheRuntime&, VideoCommon::NullBufferParams null_params)
Buffer::Buffer(BufferCacheRuntime& runtime, VideoCore::RasterizerInterface& rasterizer_, Buffer::Buffer(BufferCacheRuntime& runtime, VideoCore::RasterizerInterface& rasterizer_,
VAddr cpu_addr_, u64 size_bytes_) VAddr cpu_addr_, u64 size_bytes_)
: VideoCommon::BufferBase<VideoCore::RasterizerInterface>(rasterizer_, cpu_addr_, size_bytes_), : VideoCommon::BufferBase<VideoCore::RasterizerInterface>(rasterizer_, cpu_addr_, size_bytes_),
device{&runtime.device}, buffer{ device{&runtime.device},
CreateBuffer(*device, runtime.memory_allocator, SizeBytes())} { buffer{CreateBuffer(*device, runtime.memory_allocator, SizeBytes())} {
if (runtime.device.HasDebuggingToolAttached()) { if (runtime.device.HasDebuggingToolAttached()) {
buffer.SetObjectNameEXT(fmt::format("Buffer 0x{:x}", CpuAddr()).c_str()); buffer.SetObjectNameEXT(fmt::format("Buffer 0x{:x}", CpuAddr()).c_str());
} }
@ -206,8 +206,8 @@ public:
const size_t sub_first_offset = static_cast<size_t>(first % 4) * GetQuadsNum(num_indices); const size_t sub_first_offset = static_cast<size_t>(first % 4) * GetQuadsNum(num_indices);
const size_t offset = const size_t offset =
(sub_first_offset + GetQuadsNum(first)) * 6ULL * BytesPerIndex(index_type); (sub_first_offset + GetQuadsNum(first)) * 6ULL * BytesPerIndex(index_type);
scheduler.Record([buffer = *buffer, index_type_, offset](vk::CommandBuffer cmdbuf) { scheduler.Record([buffer_ = *buffer, index_type_, offset](vk::CommandBuffer cmdbuf) {
cmdbuf.BindIndexBuffer(buffer, offset, index_type_); cmdbuf.BindIndexBuffer(buffer_, offset, index_type_);
}); });
} }
@ -528,17 +528,18 @@ void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bi
buffer_handles.push_back(handle); buffer_handles.push_back(handle);
} }
if (device.IsExtExtendedDynamicStateSupported()) { if (device.IsExtExtendedDynamicStateSupported()) {
scheduler.Record([bindings = std::move(bindings), scheduler.Record([bindings_ = std::move(bindings),
buffer_handles = std::move(buffer_handles)](vk::CommandBuffer cmdbuf) { buffer_handles_ = std::move(buffer_handles)](vk::CommandBuffer cmdbuf) {
cmdbuf.BindVertexBuffers2EXT( cmdbuf.BindVertexBuffers2EXT(bindings_.min_index,
bindings.min_index, bindings.max_index - bindings.min_index, buffer_handles.data(), bindings_.max_index - bindings_.min_index,
bindings.offsets.data(), bindings.sizes.data(), bindings.strides.data()); buffer_handles_.data(), bindings_.offsets.data(),
bindings_.sizes.data(), bindings_.strides.data());
}); });
} else { } else {
scheduler.Record([bindings = std::move(bindings), scheduler.Record([bindings_ = std::move(bindings),
buffer_handles = std::move(buffer_handles)](vk::CommandBuffer cmdbuf) { buffer_handles_ = std::move(buffer_handles)](vk::CommandBuffer cmdbuf) {
cmdbuf.BindVertexBuffers(bindings.min_index, bindings.max_index - bindings.min_index, cmdbuf.BindVertexBuffers(bindings_.min_index, bindings_.max_index - bindings_.min_index,
buffer_handles.data(), bindings.offsets.data()); buffer_handles_.data(), bindings_.offsets.data());
}); });
} }
} }
@ -573,11 +574,11 @@ void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings<
for (u32 index = 0; index < bindings.buffers.size(); ++index) { for (u32 index = 0; index < bindings.buffers.size(); ++index) {
buffer_handles.push_back(bindings.buffers[index]->Handle()); buffer_handles.push_back(bindings.buffers[index]->Handle());
} }
scheduler.Record([bindings = std::move(bindings), scheduler.Record([bindings_ = std::move(bindings),
buffer_handles = std::move(buffer_handles)](vk::CommandBuffer cmdbuf) { buffer_handles_ = std::move(buffer_handles)](vk::CommandBuffer cmdbuf) {
cmdbuf.BindTransformFeedbackBuffersEXT(0, static_cast<u32>(buffer_handles.size()), cmdbuf.BindTransformFeedbackBuffersEXT(0, static_cast<u32>(buffer_handles_.size()),
buffer_handles.data(), bindings.offsets.data(), buffer_handles_.data(), bindings_.offsets.data(),
bindings.sizes.data()); bindings_.sizes.data());
}); });
} }

View File

@ -469,9 +469,9 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading
ComputePipelineCacheKey key; ComputePipelineCacheKey key;
file.read(reinterpret_cast<char*>(&key), sizeof(key)); file.read(reinterpret_cast<char*>(&key), sizeof(key));
workers.QueueWork([this, key, env = std::move(env), &state, &callback]() mutable { workers.QueueWork([this, key, env_ = std::move(env), &state, &callback]() mutable {
ShaderPools pools; ShaderPools pools;
auto pipeline{CreateComputePipeline(pools, key, env, state.statistics.get(), false)}; auto pipeline{CreateComputePipeline(pools, key, env_, state.statistics.get(), false)};
std::scoped_lock lock{state.mutex}; std::scoped_lock lock{state.mutex};
if (pipeline) { if (pipeline) {
compute_cache.emplace(key, std::move(pipeline)); compute_cache.emplace(key, std::move(pipeline));
@ -500,10 +500,10 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading
(key.state.dynamic_vertex_input != 0) != dynamic_features.has_dynamic_vertex_input) { (key.state.dynamic_vertex_input != 0) != dynamic_features.has_dynamic_vertex_input) {
return; return;
} }
workers.QueueWork([this, key, envs = std::move(envs), &state, &callback]() mutable { workers.QueueWork([this, key, envs_ = std::move(envs), &state, &callback]() mutable {
ShaderPools pools; ShaderPools pools;
boost::container::static_vector<Shader::Environment*, 5> env_ptrs; boost::container::static_vector<Shader::Environment*, 5> env_ptrs;
for (auto& env : envs) { for (auto& env : envs_) {
env_ptrs.push_back(&env); env_ptrs.push_back(&env);
} }
auto pipeline{CreateGraphicsPipeline(pools, key, MakeSpan(env_ptrs), auto pipeline{CreateGraphicsPipeline(pools, key, MakeSpan(env_ptrs),
@ -702,8 +702,8 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
if (!pipeline || pipeline_cache_filename.empty()) { if (!pipeline || pipeline_cache_filename.empty()) {
return pipeline; return pipeline;
} }
serialization_thread.QueueWork([this, key, env = std::move(env)] { serialization_thread.QueueWork([this, key, env_ = std::move(env)] {
SerializePipeline(key, std::array<const GenericEnvironment*, 1>{&env}, SerializePipeline(key, std::array<const GenericEnvironment*, 1>{&env_},
pipeline_cache_filename, CACHE_VERSION); pipeline_cache_filename, CACHE_VERSION);
}); });
return pipeline; return pipeline;

View File

@ -98,10 +98,10 @@ HostCounter::HostCounter(QueryCache& cache_, std::shared_ptr<HostCounter> depend
: HostCounterBase{std::move(dependency_)}, cache{cache_}, type{type_}, : HostCounterBase{std::move(dependency_)}, cache{cache_}, type{type_},
query{cache_.AllocateQuery(type_)}, tick{cache_.GetScheduler().CurrentTick()} { query{cache_.AllocateQuery(type_)}, tick{cache_.GetScheduler().CurrentTick()} {
const vk::Device* logical = &cache.GetDevice().GetLogical(); const vk::Device* logical = &cache.GetDevice().GetLogical();
cache.GetScheduler().Record([logical, query = query](vk::CommandBuffer cmdbuf) { cache.GetScheduler().Record([logical, query_ = query](vk::CommandBuffer cmdbuf) {
const bool use_precise = Settings::IsGPULevelHigh(); const bool use_precise = Settings::IsGPULevelHigh();
logical->ResetQueryPool(query.first, query.second, 1); logical->ResetQueryPool(query_.first, query_.second, 1);
cmdbuf.BeginQuery(query.first, query.second, cmdbuf.BeginQuery(query_.first, query_.second,
use_precise ? VK_QUERY_CONTROL_PRECISE_BIT : 0); use_precise ? VK_QUERY_CONTROL_PRECISE_BIT : 0);
}); });
} }
@ -111,8 +111,9 @@ HostCounter::~HostCounter() {
} }
void HostCounter::EndQuery() { void HostCounter::EndQuery() {
cache.GetScheduler().Record( cache.GetScheduler().Record([query_ = query](vk::CommandBuffer cmdbuf) {
[query = query](vk::CommandBuffer cmdbuf) { cmdbuf.EndQuery(query.first, query.second); }); cmdbuf.EndQuery(query_.first, query_.second);
});
} }
u64 HostCounter::BlockingQuery(bool async) const { u64 HostCounter::BlockingQuery(bool async) const {

View File

@ -1412,7 +1412,7 @@ void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<VkDeviceS
} }
scheduler->RequestOutsideRenderPassOperationContext(); scheduler->RequestOutsideRenderPassOperationContext();
scheduler->Record([buffers = std::move(buffers_vector), image = *original_image, scheduler->Record([buffers = std::move(buffers_vector), image = *original_image,
aspect_mask = aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) { aspect_mask_ = aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) {
const VkImageMemoryBarrier read_barrier{ const VkImageMemoryBarrier read_barrier{
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
.pNext = nullptr, .pNext = nullptr,
@ -1424,7 +1424,7 @@ void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<VkDeviceS
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = image, .image = image,
.subresourceRange{ .subresourceRange{
.aspectMask = aspect_mask, .aspectMask = aspect_mask_,
.baseMipLevel = 0, .baseMipLevel = 0,
.levelCount = VK_REMAINING_MIP_LEVELS, .levelCount = VK_REMAINING_MIP_LEVELS,
.baseArrayLayer = 0, .baseArrayLayer = 0,
@ -1456,7 +1456,7 @@ void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<VkDeviceS
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = image, .image = image,
.subresourceRange{ .subresourceRange{
.aspectMask = aspect_mask, .aspectMask = aspect_mask_,
.baseMipLevel = 0, .baseMipLevel = 0,
.levelCount = VK_REMAINING_MIP_LEVELS, .levelCount = VK_REMAINING_MIP_LEVELS,
.baseArrayLayer = 0, .baseArrayLayer = 0,

View File

@ -135,10 +135,10 @@ void RoomJson::Delete() {
LOG_ERROR(WebService, "Room must be registered to be deleted"); LOG_ERROR(WebService, "Room must be registered to be deleted");
return; return;
} }
Common::DetachedTasks::AddTask( Common::DetachedTasks::AddTask([host_{this->host}, username_{this->username},
[host{this->host}, username{this->username}, token{this->token}, room_id{this->room_id}]() { token_{this->token}, room_id_{this->room_id}]() {
// create a new client here because the this->client might be destroyed. // create a new client here because the this->client might be destroyed.
Client{host, username, token}.DeleteJson(fmt::format("/lobby/{}", room_id), "", false); Client{host_, username_, token_}.DeleteJson(fmt::format("/lobby/{}", room_id_), "", false);
}); });
} }