summaryrefslogtreecommitdiffstats
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-02-19 12:56:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-02-19 12:56:41 (GMT)
commit2bff8513f22ae02d1559851d0eb814083d015a2e (patch)
tree4fe58a01edfb6a846f1679bbfa86c5703ece47fa /Source/cmcmd.cxx
parent9cab31cc79b9c19f2a5121a392a3498d06e25723 (diff)
parent706b93fa558c5a2e0e45a7068b5039d1f40fbc90 (diff)
downloadCMake-2bff8513f22ae02d1559851d0eb814083d015a2e.zip
CMake-2bff8513f22ae02d1559851d0eb814083d015a2e.tar.gz
CMake-2bff8513f22ae02d1559851d0eb814083d015a2e.tar.bz2
Merge topic 'modernize-for-loops-c-arrays'
706b93fa55 Modernize: C-arrays and loops over them Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2951
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx30
1 files changed, 15 insertions, 15 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 21802ad..adfce37 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -37,6 +37,7 @@
#include "cmsys/Process.h"
#include "cmsys/Terminal.h"
#include <algorithm>
+#include <array>
#include <iostream>
#include <iterator>
#include <memory> // IWYU pragma: keep
@@ -350,12 +351,13 @@ struct CoCompiler
bool NoOriginalCommand;
};
-static CoCompiler CoCompilers[] = { // Table of options and handlers.
- { "--cppcheck=", HandleCppCheck, false },
- { "--cpplint=", HandleCppLint, false },
- { "--iwyu=", HandleIWYU, false },
- { "--lwyu=", HandleLWYU, true },
- { "--tidy=", HandleTidy, false }
+static const std::array<CoCompiler, 5> CoCompilers = {
+ { // Table of options and handlers.
+ { "--cppcheck=", HandleCppCheck, false },
+ { "--cpplint=", HandleCppLint, false },
+ { "--iwyu=", HandleIWYU, false },
+ { "--lwyu=", HandleLWYU, true },
+ { "--tidy=", HandleTidy, false } }
};
struct CoCompileJob
@@ -386,16 +388,15 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args)
doing_options = false;
} else if (doing_options) {
bool optionFound = false;
- for (CoCompiler const* cc = cm::cbegin(CoCompilers);
- cc != cm::cend(CoCompilers); ++cc) {
- size_t optionLen = strlen(cc->Option);
- if (arg.compare(0, optionLen, cc->Option) == 0) {
+ for (CoCompiler const& cc : CoCompilers) {
+ size_t optionLen = strlen(cc.Option);
+ if (arg.compare(0, optionLen, cc.Option) == 0) {
optionFound = true;
CoCompileJob job;
job.Command = arg.substr(optionLen);
- job.Handler = cc->Handler;
+ job.Handler = cc.Handler;
jobs.push_back(std::move(job));
- if (cc->NoOriginalCommand) {
+ if (cc.NoOriginalCommand) {
runOriginalCmd = false;
}
}
@@ -419,9 +420,8 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args)
if (jobs.empty()) {
std::cerr << "__run_co_compile missing command to run. "
"Looking for one or more of the following:\n";
- for (CoCompiler const* cc = cm::cbegin(CoCompilers);
- cc != cm::cend(CoCompilers); ++cc) {
- std::cerr << cc->Option << "\n";
+ for (CoCompiler const& cc : CoCompilers) {
+ std::cerr << cc.Option << "\n";
}
return 1;
}