From 1f6a299062381ec3f317d50fa97efd1fbfb3e98e Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Thu, 1 Sep 2022 10:55:29 +0200 Subject: [PATCH] Add a check for unqualified move --- libyul/backends/evm/EVMDialect.cpp | 2 +- scripts/check_style.sh | 2 ++ solc/CommandLineInterface.cpp | 10 +++++----- solc/CommandLineParser.cpp | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 0f5c307e3..71b9dba4c 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -83,7 +83,7 @@ pair createEVMFunction( }; YulString name = f.name; - return {name, move(f)}; + return {name, std::move(f)}; } pair createFunction( diff --git a/scripts/check_style.sh b/scripts/check_style.sh index 601981b5c..d1ad6bb9e 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -54,6 +54,8 @@ FORMATERROR=$( preparedGrep "[a-zA-Z0-9_]\s*[&][a-zA-Z_]" | grep -E -v "return [&]" # right-aligned reference ampersand (needs to exclude return) # right-aligned reference pointer star (needs to exclude return and comments) preparedGrep "[a-zA-Z0-9_]\s*[*][a-zA-Z_]" | grep -E -v -e "return [*]" -e "^* [*]" -e "^*//.*" + # unqualified move check, i.e. make sure that std::move() is used instead of move() + preparedGrep "move\(.+\)" | grep -v "std::move" | grep -E "[^a-z]move" ) | grep -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" || true ) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index f841c2b63..e215405a1 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -498,11 +498,11 @@ void CommandLineInterface::readInputFiles() if (m_options.input.mode == InputMode::StandardJson) { solAssert(!m_standardJsonInput.has_value(), ""); - m_standardJsonInput = move(fileContent); + m_standardJsonInput = std::move(fileContent); } else { - m_fileReader.addOrUpdateFile(infile, move(fileContent)); + m_fileReader.addOrUpdateFile(infile, std::move(fileContent)); m_fileReader.allowDirectory(boost::filesystem::canonical(infile).remove_filename()); } } @@ -546,7 +546,7 @@ map CommandLineInterface::parseAstFromInput() astAssert(ast["sources"][src].isMember(astKey), "astkey is not member"); astAssert(ast["sources"][src][astKey]["nodeType"].asString() == "SourceUnit", "Top-level node should be a 'SourceUnit'"); astAssert(sourceJsons.count(src) == 0, "All sources must have unique names"); - sourceJsons.emplace(src, move(ast["sources"][src][astKey])); + sourceJsons.emplace(src, std::move(ast["sources"][src][astKey])); tmpSources[src] = util::jsonCompactPrint(ast); } } @@ -643,7 +643,7 @@ void CommandLineInterface::processInput() solAssert(m_standardJsonInput.has_value(), ""); StandardCompiler compiler(m_fileReader.reader(), m_options.formatting.json); - sout() << compiler.compile(move(m_standardJsonInput.value())) << endl; + sout() << compiler.compile(std::move(m_standardJsonInput.value())) << endl; m_standardJsonInput.reset(); break; } @@ -977,7 +977,7 @@ void CommandLineInterface::link() while (!src.second.empty() && *prev(src.second.end()) == '\n') src.second.resize(src.second.size() - 1); } - m_fileReader.setSourceUnits(move(sourceCodes)); + m_fileReader.setSourceUnits(std::move(sourceCodes)); } void CommandLineInterface::writeLinkedFiles() diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 319f29de6..2c765d0e3 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -309,7 +309,7 @@ void CommandLineParser::parseInputPathsAndRemappings() m_options.input.allowedDirectories.insert(remappingDir.empty() ? "." : remappingDir); } - m_options.input.remappings.emplace_back(move(remapping.value())); + m_options.input.remappings.emplace_back(std::move(remapping.value())); } else if (positionalArg == "-") m_options.input.addStdin = true; @@ -1218,7 +1218,7 @@ void CommandLineParser::processArgs() optional contracts = ModelCheckerContracts::fromString(contractsStr); if (!contracts) solThrow(CommandLineValidationError, "Invalid option for --" + g_strModelCheckerContracts + ": " + contractsStr); - m_options.modelChecker.settings.contracts = move(*contracts); + m_options.modelChecker.settings.contracts = std::move(*contracts); } if (m_args.count(g_strModelCheckerDivModNoSlacks))