Skip to content

Commit

Permalink
Add a check for unqualified move
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-matic committed Sep 5, 2022
1 parent 99f15ff commit 1f6a299
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libyul/backends/evm/EVMDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pair<YulString, BuiltinFunctionForEVM> createEVMFunction(
};

YulString name = f.name;
return {name, move(f)};
return {name, std::move(f)};
}

pair<YulString, BuiltinFunctionForEVM> createFunction(
Expand Down
2 changes: 2 additions & 0 deletions scripts/check_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
10 changes: 5 additions & 5 deletions solc/CommandLineInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -546,7 +546,7 @@ map<string, Json::Value> 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);
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions solc/CommandLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1218,7 +1218,7 @@ void CommandLineParser::processArgs()
optional<ModelCheckerContracts> 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))
Expand Down

0 comments on commit 1f6a299

Please sign in to comment.