Enable clang-tidy modernize-loop-convert lint

Fix remaining diagnostics by this lint and remove it from our list of
disabled lints.
This commit is contained in:
Brad King
2017-09-18 14:11:19 -04:00
parent 4547d9a830
commit 706b37b7f5
6 changed files with 10 additions and 21 deletions

View File

@@ -8,7 +8,6 @@ misc-*,\
-misc-static-assert,\
modernize-*,\
-modernize-deprecated-headers,\
-modernize-loop-convert,\
-modernize-pass-by-value,\
-modernize-raw-string-literal,\
-modernize-replace-auto-ptr,\

View File

@@ -72,9 +72,8 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
this->Entry = ow;
std::vector<std::string> options;
cmSystemTools::ExpandListArgument(stringsProp, options);
for (std::vector<std::string>::iterator si = options.begin();
si != options.end(); ++si) {
ow->AddOption(*si);
for (auto const& opt : options) {
ow->AddOption(opt);
}
ow->SetOption(value);
} else {

View File

@@ -75,9 +75,8 @@ void cmCursesOptionsWidget::SetOption(const std::string& value)
this->CurrentOption = 0; // default to 0 index
this->SetValue(value);
int index = 0;
for (std::vector<std::string>::iterator i = this->Options.begin();
i != this->Options.end(); ++i) {
if (*i == value) {
for (auto const& opt : this->Options) {
if (opt == value) {
this->CurrentOption = index;
}
index++;

View File

@@ -188,9 +188,7 @@ bool cmCursesStringWidget::PrintKeys()
char fmt_s[] = "%s";
char firstLine[512];
// Clean the toolbar
for (int i = 0; i < 512; i++) {
firstLine[i] = ' ';
}
memset(firstLine, ' ', sizeof(firstLine));
firstLine[511] = '\0';
curses_move(y - 4, 0);
printw(fmt_s, firstLine);

View File

@@ -282,8 +282,7 @@ int cmcmd::HandleCppCheck(const std::string& runCmd,
std::vector<std::string> cppcheck_cmd;
cmSystemTools::ExpandListArgument(runCmd, cppcheck_cmd, true);
// extract all the -D, -U, and -I options from the compile line
for (size_t i = 0; i < orig_cmd.size(); i++) {
const std::string& opt = orig_cmd[i];
for (auto const& opt : orig_cmd) {
if (opt.size() > 2) {
if ((opt[0] == '-') &&
((opt[1] == 'D') || (opt[1] == 'I') || (opt[1] == 'U'))) {
@@ -367,9 +366,7 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args)
} else if (doing_options) {
bool optionFound = false;
// check arg against all the commandOptions
for (std::vector<std::string>::size_type i = 0;
i < commandOptions.size(); ++i) {
const std::string& command = commandOptions[i];
for (auto const& command : commandOptions) {
if (arg.compare(0, command.size(), command) == 0) {
optionFound = true;
runCmd = arg.substr(command.size());

View File

@@ -144,14 +144,11 @@ int main()
cmsys::ifstream file("compile_commands.json");
CompileCommandParser parser(file);
parser.Parse();
for (CompileCommandParser::TranslationUnitsType::const_iterator
it = parser.GetTranslationUnits().begin(),
end = parser.GetTranslationUnits().end();
it != end; ++it) {
for (auto const& tu : parser.GetTranslationUnits()) {
std::vector<std::string> command;
cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command);
cmSystemTools::ParseUnixCommandLine(tu.at("command").c_str(), command);
if (!cmSystemTools::RunSingleCommand(command, nullptr, nullptr, nullptr,
it->at("directory").c_str())) {
tu.at("directory").c_str())) {
std::cout << "ERROR: Failed to run command \"" << command[0] << "\""
<< std::endl;
exit(1);