Skip to content

Commit

Permalink
Qualify std::move.
Browse files Browse the repository at this point in the history
Clang added -Wunqualified-std-cast-call in
https://reviews.llvm.org/D119670, which warns on unqualified std::move
and std::forward calls. This change qualifies these calls to allow the
project to build on HEAD Clang -Werror.
  • Loading branch information
mysterymath committed Mar 2, 2022
1 parent d16183d commit 44c3333
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 64 deletions.
40 changes: 20 additions & 20 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct CLICallbacks
struct CLIParser
{
CLIParser(CLICallbacks cbs_, int argc_, char *argv_[])
: cbs(move(cbs_))
: cbs(std::move(cbs_))
, argc(argc_)
, argv(argv_)
{
Expand Down Expand Up @@ -1089,7 +1089,7 @@ static HLSLBindingFlags hlsl_resource_type_to_flag(const std::string &arg)

static string compile_iteration(const CLIArguments &args, std::vector<uint32_t> spirv_file)
{
Parser spirv_parser(move(spirv_file));
Parser spirv_parser(std::move(spirv_file));
spirv_parser.parse();

unique_ptr<CompilerGLSL> compiler;
Expand All @@ -1098,13 +1098,13 @@ static string compile_iteration(const CLIArguments &args, std::vector<uint32_t>

if (args.cpp)
{
compiler.reset(new CompilerCPP(move(spirv_parser.get_parsed_ir())));
compiler.reset(new CompilerCPP(std::move(spirv_parser.get_parsed_ir())));
if (args.cpp_interface_name)
static_cast<CompilerCPP *>(compiler.get())->set_interface_name(args.cpp_interface_name);
}
else if (args.msl)
{
compiler.reset(new CompilerMSL(move(spirv_parser.get_parsed_ir())));
compiler.reset(new CompilerMSL(std::move(spirv_parser.get_parsed_ir())));

auto *msl_comp = static_cast<CompilerMSL *>(compiler.get());
auto msl_opts = msl_comp->get_msl_options();
Expand Down Expand Up @@ -1162,13 +1162,13 @@ static string compile_iteration(const CLIArguments &args, std::vector<uint32_t>
msl_comp->set_combined_sampler_suffix(args.msl_combined_sampler_suffix);
}
else if (args.hlsl)
compiler.reset(new CompilerHLSL(move(spirv_parser.get_parsed_ir())));
compiler.reset(new CompilerHLSL(std::move(spirv_parser.get_parsed_ir())));
else
{
combined_image_samplers = !args.vulkan_semantics;
if (!args.vulkan_semantics || args.vulkan_glsl_disable_ext_samplerless_texture_functions)
build_dummy_sampler = true;
compiler.reset(new CompilerGLSL(move(spirv_parser.get_parsed_ir())));
compiler.reset(new CompilerGLSL(std::move(spirv_parser.get_parsed_ir())));
}

if (!args.variable_type_remaps.empty())
Expand All @@ -1179,7 +1179,7 @@ static string compile_iteration(const CLIArguments &args, std::vector<uint32_t>
out = remap.new_variable_type;
};

compiler->set_variable_type_remap_callback(move(remap_cb));
compiler->set_variable_type_remap_callback(std::move(remap_cb));
}

for (auto &masked : args.masked_stage_outputs)
Expand Down Expand Up @@ -1352,7 +1352,7 @@ static string compile_iteration(const CLIArguments &args, std::vector<uint32_t>
{
auto active = compiler->get_active_interface_variables();
res = compiler->get_shader_resources(active);
compiler->set_enabled_interface_variables(move(active));
compiler->set_enabled_interface_variables(std::move(active));
}
else
res = compiler->get_shader_resources();
Expand All @@ -1367,7 +1367,7 @@ static string compile_iteration(const CLIArguments &args, std::vector<uint32_t>

auto pls_inputs = remap_pls(args.pls_in, res.stage_inputs, &res.subpass_inputs);
auto pls_outputs = remap_pls(args.pls_out, res.stage_outputs, nullptr);
compiler->remap_pixel_local_storage(move(pls_inputs), move(pls_outputs));
compiler->remap_pixel_local_storage(std::move(pls_inputs), std::move(pls_outputs));

for (auto &ext : args.extensions)
compiler->require_extension(ext);
Expand Down Expand Up @@ -1596,7 +1596,7 @@ static int main_inner(int argc, char *argv[])
auto old_name = parser.next_string();
auto new_name = parser.next_string();
auto model = stage_to_execution_model(parser.next_string());
args.entry_point_rename.push_back({ old_name, new_name, move(model) });
args.entry_point_rename.push_back({ old_name, new_name, std::move(model) });
});
cbs.add("--entry", [&args](CLIParser &parser) { args.entry = parser.next_string(); });
cbs.add("--stage", [&args](CLIParser &parser) { args.entry_stage = parser.next_string(); });
Expand All @@ -1605,20 +1605,20 @@ static int main_inner(int argc, char *argv[])
HLSLVertexAttributeRemap remap;
remap.location = parser.next_uint();
remap.semantic = parser.next_string();
args.hlsl_attr_remap.push_back(move(remap));
args.hlsl_attr_remap.push_back(std::move(remap));
});

cbs.add("--remap", [&args](CLIParser &parser) {
string src = parser.next_string();
string dst = parser.next_string();
uint32_t components = parser.next_uint();
args.remaps.push_back({ move(src), move(dst), components });
args.remaps.push_back({ std::move(src), std::move(dst), components });
});

cbs.add("--remap-variable-type", [&args](CLIParser &parser) {
string var_name = parser.next_string();
string new_type = parser.next_string();
args.variable_type_remaps.push_back({ move(var_name), move(new_type) });
args.variable_type_remaps.push_back({ std::move(var_name), std::move(new_type) });
});

cbs.add("--rename-interface-variable", [&args](CLIParser &parser) {
Expand All @@ -1631,18 +1631,18 @@ static int main_inner(int argc, char *argv[])

uint32_t loc = parser.next_uint();
string var_name = parser.next_string();
args.interface_variable_renames.push_back({ cls, loc, move(var_name) });
args.interface_variable_renames.push_back({ cls, loc, std::move(var_name) });
});

cbs.add("--pls-in", [&args](CLIParser &parser) {
auto fmt = pls_format(parser.next_string());
auto name = parser.next_string();
args.pls_in.push_back({ move(fmt), move(name) });
args.pls_in.push_back({ std::move(fmt), std::move(name) });
});
cbs.add("--pls-out", [&args](CLIParser &parser) {
auto fmt = pls_format(parser.next_string());
auto name = parser.next_string();
args.pls_out.push_back({ move(fmt), move(name) });
args.pls_out.push_back({ std::move(fmt), std::move(name) });
});
cbs.add("--shader-model", [&args](CLIParser &parser) {
args.shader_model = parser.next_uint();
Expand Down Expand Up @@ -1693,7 +1693,7 @@ static int main_inner(int argc, char *argv[])
cbs.add("-", [&args](CLIParser &) { args.input = "-"; });
cbs.error_handler = [] { print_help(); };

CLIParser parser{ move(cbs), argc - 1, argv + 1 };
CLIParser parser{ std::move(cbs), argc - 1, argv + 1 };
if (!parser.parse())
return EXIT_FAILURE;
else if (parser.ended_state)
Expand All @@ -1713,10 +1713,10 @@ static int main_inner(int argc, char *argv[])
// Special case reflection because it has little to do with the path followed by code-outputting compilers
if (!args.reflect.empty())
{
Parser spirv_parser(move(spirv_file));
Parser spirv_parser(std::move(spirv_file));
spirv_parser.parse();

CompilerReflection compiler(move(spirv_parser.get_parsed_ir()));
CompilerReflection compiler(std::move(spirv_parser.get_parsed_ir()));
compiler.set_format(args.reflect);
auto json = compiler.compile();
if (args.output)
Expand All @@ -1729,7 +1729,7 @@ static int main_inner(int argc, char *argv[])
string compiled_output;

if (args.iterations == 1)
compiled_output = compile_iteration(args, move(spirv_file));
compiled_output = compile_iteration(args, std::move(spirv_file));
else
{
for (unsigned i = 0; i < args.iterations; i++)
Expand Down
20 changes: 10 additions & 10 deletions spirv_cross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ using namespace SPIRV_CROSS_NAMESPACE;

Compiler::Compiler(vector<uint32_t> ir_)
{
Parser parser(move(ir_));
Parser parser(std::move(ir_));
parser.parse();
set_ir(move(parser.get_parsed_ir()));
set_ir(std::move(parser.get_parsed_ir()));
}

Compiler::Compiler(const uint32_t *ir_, size_t word_count)
{
Parser parser(ir_, word_count);
parser.parse();
set_ir(move(parser.get_parsed_ir()));
set_ir(std::move(parser.get_parsed_ir()));
}

Compiler::Compiler(const ParsedIR &ir_)
Expand All @@ -55,12 +55,12 @@ Compiler::Compiler(const ParsedIR &ir_)

Compiler::Compiler(ParsedIR &&ir_)
{
set_ir(move(ir_));
set_ir(std::move(ir_));
}

void Compiler::set_ir(ParsedIR &&ir_)
{
ir = move(ir_);
ir = std::move(ir_);
parse_fixup();
}

Expand Down Expand Up @@ -852,7 +852,7 @@ unordered_set<VariableID> Compiler::get_active_interface_variables() const

void Compiler::set_enabled_interface_variables(std::unordered_set<VariableID> active_variables)
{
active_interface_variables = move(active_variables);
active_interface_variables = std::move(active_variables);
check_active_interface_variables = true;
}

Expand Down Expand Up @@ -2513,7 +2513,7 @@ void Compiler::CombinedImageSamplerHandler::push_remap_parameters(const SPIRFunc
unordered_map<uint32_t, uint32_t> remapping;
for (uint32_t i = 0; i < length; i++)
remapping[func.arguments[i].id] = remap_parameter(args[i]);
parameter_remapping.push(move(remapping));
parameter_remapping.push(std::move(remapping));
}

void Compiler::CombinedImageSamplerHandler::pop_remap_parameters()
Expand Down Expand Up @@ -4367,7 +4367,7 @@ void Compiler::analyze_image_and_sampler_usage()
handler.dependency_hierarchy.clear();
traverse_all_reachable_opcodes(get<SPIRFunction>(ir.default_entry_point), handler);

comparison_ids = move(handler.comparison_ids);
comparison_ids = std::move(handler.comparison_ids);
need_subpass_input = handler.need_subpass_input;

// Forward information from separate images and samplers into combined image samplers.
Expand Down Expand Up @@ -4420,7 +4420,7 @@ void Compiler::build_function_control_flow_graphs_and_analyze()
CFGBuilder handler(*this);
handler.function_cfgs[ir.default_entry_point].reset(new CFG(*this, get<SPIRFunction>(ir.default_entry_point)));
traverse_all_reachable_opcodes(get<SPIRFunction>(ir.default_entry_point), handler);
function_cfgs = move(handler.function_cfgs);
function_cfgs = std::move(handler.function_cfgs);
bool single_function = function_cfgs.size() <= 1;

for (auto &f : function_cfgs)
Expand Down Expand Up @@ -5029,7 +5029,7 @@ void Compiler::analyze_non_block_pointer_types()
for (auto type : handler.non_block_types)
physical_storage_non_block_pointer_types.push_back(type);
sort(begin(physical_storage_non_block_pointer_types), end(physical_storage_non_block_pointer_types));
physical_storage_type_to_alignment = move(handler.physical_block_type_meta);
physical_storage_type_to_alignment = std::move(handler.physical_block_type_meta);
}

bool Compiler::InterlockedResourceAccessPrepassHandler::handle(Op op, const uint32_t *, uint32_t)
Expand Down
14 changes: 7 additions & 7 deletions spirv_cross_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ spvc_result spvc_context_parse_spirv(spvc_context context, const SpvId *spirv, s
pir->context = context;
Parser parser(spirv, word_count);
parser.parse();
pir->parsed = move(parser.get_parsed_ir());
pir->parsed = std::move(parser.get_parsed_ir());
*parsed_ir = pir.get();
context->allocations.push_back(std::move(pir));
}
Expand Down Expand Up @@ -283,15 +283,15 @@ spvc_result spvc_context_create_compiler(spvc_context context, spvc_backend back
{
case SPVC_BACKEND_NONE:
if (mode == SPVC_CAPTURE_MODE_TAKE_OWNERSHIP)
comp->compiler.reset(new Compiler(move(parsed_ir->parsed)));
comp->compiler.reset(new Compiler(std::move(parsed_ir->parsed)));
else if (mode == SPVC_CAPTURE_MODE_COPY)
comp->compiler.reset(new Compiler(parsed_ir->parsed));
break;

#if SPIRV_CROSS_C_API_GLSL
case SPVC_BACKEND_GLSL:
if (mode == SPVC_CAPTURE_MODE_TAKE_OWNERSHIP)
comp->compiler.reset(new CompilerGLSL(move(parsed_ir->parsed)));
comp->compiler.reset(new CompilerGLSL(std::move(parsed_ir->parsed)));
else if (mode == SPVC_CAPTURE_MODE_COPY)
comp->compiler.reset(new CompilerGLSL(parsed_ir->parsed));
break;
Expand All @@ -300,7 +300,7 @@ spvc_result spvc_context_create_compiler(spvc_context context, spvc_backend back
#if SPIRV_CROSS_C_API_HLSL
case SPVC_BACKEND_HLSL:
if (mode == SPVC_CAPTURE_MODE_TAKE_OWNERSHIP)
comp->compiler.reset(new CompilerHLSL(move(parsed_ir->parsed)));
comp->compiler.reset(new CompilerHLSL(std::move(parsed_ir->parsed)));
else if (mode == SPVC_CAPTURE_MODE_COPY)
comp->compiler.reset(new CompilerHLSL(parsed_ir->parsed));
break;
Expand All @@ -309,7 +309,7 @@ spvc_result spvc_context_create_compiler(spvc_context context, spvc_backend back
#if SPIRV_CROSS_C_API_MSL
case SPVC_BACKEND_MSL:
if (mode == SPVC_CAPTURE_MODE_TAKE_OWNERSHIP)
comp->compiler.reset(new CompilerMSL(move(parsed_ir->parsed)));
comp->compiler.reset(new CompilerMSL(std::move(parsed_ir->parsed)));
else if (mode == SPVC_CAPTURE_MODE_COPY)
comp->compiler.reset(new CompilerMSL(parsed_ir->parsed));
break;
Expand All @@ -318,7 +318,7 @@ spvc_result spvc_context_create_compiler(spvc_context context, spvc_backend back
#if SPIRV_CROSS_C_API_CPP
case SPVC_BACKEND_CPP:
if (mode == SPVC_CAPTURE_MODE_TAKE_OWNERSHIP)
comp->compiler.reset(new CompilerCPP(move(parsed_ir->parsed)));
comp->compiler.reset(new CompilerCPP(std::move(parsed_ir->parsed)));
else if (mode == SPVC_CAPTURE_MODE_COPY)
comp->compiler.reset(new CompilerCPP(parsed_ir->parsed));
break;
Expand All @@ -327,7 +327,7 @@ spvc_result spvc_context_create_compiler(spvc_context context, spvc_backend back
#if SPIRV_CROSS_C_API_REFLECT
case SPVC_BACKEND_JSON:
if (mode == SPVC_CAPTURE_MODE_TAKE_OWNERSHIP)
comp->compiler.reset(new CompilerReflection(move(parsed_ir->parsed)));
comp->compiler.reset(new CompilerReflection(std::move(parsed_ir->parsed)));
else if (mode == SPVC_CAPTURE_MODE_COPY)
comp->compiler.reset(new CompilerReflection(parsed_ir->parsed));
break;
Expand Down
28 changes: 14 additions & 14 deletions spirv_cross_parsed_ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ ParsedIR::ParsedIR()
// Should have been default-implemented, but need this on MSVC 2013.
ParsedIR::ParsedIR(ParsedIR &&other) SPIRV_CROSS_NOEXCEPT
{
*this = move(other);
*this = std::move(other);
}

ParsedIR &ParsedIR::operator=(ParsedIR &&other) SPIRV_CROSS_NOEXCEPT
{
if (this != &other)
{
pool_group = move(other.pool_group);
spirv = move(other.spirv);
meta = move(other.meta);
pool_group = std::move(other.pool_group);
spirv = std::move(other.spirv);
meta = std::move(other.meta);
for (int i = 0; i < TypeCount; i++)
ids_for_type[i] = move(other.ids_for_type[i]);
ids_for_constant_or_type = move(other.ids_for_constant_or_type);
ids_for_constant_or_variable = move(other.ids_for_constant_or_variable);
declared_capabilities = move(other.declared_capabilities);
declared_extensions = move(other.declared_extensions);
block_meta = move(other.block_meta);
continue_block_to_loop_header = move(other.continue_block_to_loop_header);
entry_points = move(other.entry_points);
ids = move(other.ids);
ids_for_type[i] = std::move(other.ids_for_type[i]);
ids_for_constant_or_type = std::move(other.ids_for_constant_or_type);
ids_for_constant_or_variable = std::move(other.ids_for_constant_or_variable);
declared_capabilities = std::move(other.declared_capabilities);
declared_extensions = std::move(other.declared_extensions);
block_meta = std::move(other.block_meta);
continue_block_to_loop_header = std::move(other.continue_block_to_loop_header);
entry_points = std::move(other.entry_points);
ids = std::move(other.ids);
addressing_model = other.addressing_model;
memory_model = other.memory_model;

Expand Down Expand Up @@ -999,7 +999,7 @@ ParsedIR::LoopLock::LoopLock(uint32_t *lock_)

ParsedIR::LoopLock::LoopLock(LoopLock &&other) SPIRV_CROSS_NOEXCEPT
{
*this = move(other);
*this = std::move(other);
}

ParsedIR::LoopLock &ParsedIR::LoopLock::operator=(LoopLock &&other) SPIRV_CROSS_NOEXCEPT
Expand Down
10 changes: 5 additions & 5 deletions spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10248,8 +10248,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
requires_temporary = !backend.can_declare_struct_inline;

auto &expr = requires_temporary ?
emit_op(ops[0], ops[1], move(e), false) :
set<SPIRExpression>(ops[1], move(e), ops[0], should_forward(ops[2]));
emit_op(ops[0], ops[1], std::move(e), false) :
set<SPIRExpression>(ops[1], std::move(e), ops[0], should_forward(ops[2]));

auto *backing_variable = maybe_get_backing_variable(ops[2]);
expr.loaded_from = backing_variable ? backing_variable->self : ID(ops[2]);
Expand Down Expand Up @@ -15517,7 +15517,7 @@ void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t s
statement(new_expr, "[i] = ", expr, "[i];");
end_scope();

expr = move(new_expr);
expr = std::move(new_expr);
}
}

Expand Down Expand Up @@ -15852,7 +15852,7 @@ void CompilerGLSL::emit_copy_logical_type(uint32_t lhs_id, uint32_t lhs_type_id,
rhs_id = id + 1;

{
auto &lhs_expr = set<SPIRExpression>(lhs_id, move(lhs), lhs_type_id, true);
auto &lhs_expr = set<SPIRExpression>(lhs_id, std::move(lhs), lhs_type_id, true);
lhs_expr.need_transpose = lhs_meta.need_transpose;

if (lhs_meta.storage_is_packed)
Expand All @@ -15865,7 +15865,7 @@ void CompilerGLSL::emit_copy_logical_type(uint32_t lhs_id, uint32_t lhs_type_id,
}

{
auto &rhs_expr = set<SPIRExpression>(rhs_id, move(rhs), rhs_type_id, true);
auto &rhs_expr = set<SPIRExpression>(rhs_id, std::move(rhs), rhs_type_id, true);
rhs_expr.need_transpose = rhs_meta.need_transpose;

if (rhs_meta.storage_is_packed)
Expand Down

0 comments on commit 44c3333

Please sign in to comment.