浏览代码

clang-tidy: isolate declarations for readability

Regina Pfeifer 6 年之前
父节点
当前提交
d331021255

+ 0 - 1
.clang-tidy

@@ -28,7 +28,6 @@ readability-*,\
 -readability-implicit-bool-cast,\
 -readability-implicit-bool-conversion,\
 -readability-inconsistent-declaration-parameter-name,\
--readability-isolate-declaration,\
 -readability-magic-numbers,\
 -readability-named-parameter,\
 -readability-redundant-declaration,\

+ 4 - 2
Source/CursesDialog/ccmake.cxx

@@ -56,7 +56,8 @@ void onsig(int /*unused*/)
     cbreak();             /* nl- or cr not needed */
     keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
     refresh();
-    int x, y;
+    int x;
+    int y;
     getmaxyx(stdscr, y, x);
     cmCursesForm::CurrentForm->Render(1, 1, x, y);
     cmCursesForm::CurrentForm->UpdateStatusBar();
@@ -127,7 +128,8 @@ int main(int argc, char const* const* argv)
 
   signal(SIGWINCH, onsig);
 
-  int x, y;
+  int x;
+  int y;
   getmaxyx(stdscr, y, x);
   if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
     endwin();

+ 6 - 3
Source/CursesDialog/cmCursesLongMessageForm.cxx

@@ -38,7 +38,8 @@ cmCursesLongMessageForm::~cmCursesLongMessageForm()
 
 void cmCursesLongMessageForm::UpdateStatusBar()
 {
-  int x, y;
+  int x;
+  int y;
   getmaxyx(stdscr, y, x);
 
   char bar[cmCursesMainForm::MAX_WIDTH];
@@ -81,7 +82,8 @@ void cmCursesLongMessageForm::UpdateStatusBar()
 
 void cmCursesLongMessageForm::PrintKeys()
 {
-  int x, y;
+  int x;
+  int y;
   getmaxyx(stdscr, y, x);
   if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
     return;
@@ -98,7 +100,8 @@ void cmCursesLongMessageForm::PrintKeys()
 void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/,
                                      int /*height*/)
 {
-  int x, y;
+  int x;
+  int y;
   getmaxyx(stdscr, y, x);
 
   if (this->Form) {

+ 14 - 7
Source/CursesDialog/cmCursesMainForm.cxx

@@ -320,7 +320,8 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
 
 void cmCursesMainForm::PrintKeys(int process /* = 0 */)
 {
-  int x, y;
+  int x;
+  int y;
   getmaxyx(stdscr, y, x);
   if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
       y < cmCursesMainForm::MIN_HEIGHT) {
@@ -391,7 +392,8 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
 // on the status bar. Designed for a width of 80 chars.
 void cmCursesMainForm::UpdateStatusBar(const char* message)
 {
-  int x, y;
+  int x;
+  int y;
   getmaxyx(stdscr, y, x);
   // If window size is too small, display error and return
   if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
@@ -509,7 +511,8 @@ void cmCursesMainForm::UpdateProgress(const std::string& msg, float prog)
 
 int cmCursesMainForm::Configure(int noconfigure)
 {
-  int xi, yi;
+  int xi;
+  int yi;
   getmaxyx(stdscr, yi, xi);
 
   curses_move(1, 1);
@@ -552,7 +555,8 @@ int cmCursesMainForm::Configure(int noconfigure)
     if (cmSystemTools::GetErrorOccuredFlag()) {
       this->OkToGenerate = false;
     }
-    int xx, yy;
+    int xx;
+    int yy;
     getmaxyx(stdscr, yy, xx);
     cmCursesLongMessageForm* msgs =
       new cmCursesLongMessageForm(this->Errors,
@@ -581,7 +585,8 @@ int cmCursesMainForm::Configure(int noconfigure)
 
 int cmCursesMainForm::Generate()
 {
-  int xi, yi;
+  int xi;
+  int yi;
   getmaxyx(stdscr, yi, xi);
 
   curses_move(1, 1);
@@ -610,7 +615,8 @@ int cmCursesMainForm::Generate()
     }
     // reset error condition
     cmSystemTools::ResetErrorOccuredFlag();
-    int xx, yy;
+    int xx;
+    int yy;
     getmaxyx(stdscr, yy, xx);
     const char* title = "Messages during last pass.";
     if (cmSystemTools::GetErrorOccuredFlag()) {
@@ -707,7 +713,8 @@ void cmCursesMainForm::FixValue(cmStateEnums::CacheEntryType type,
 
 void cmCursesMainForm::HandleInput()
 {
-  int x = 0, y = 0;
+  int x = 0;
+  int y = 0;
 
   if (!this->Form) {
     return;

+ 4 - 2
Source/CursesDialog/cmCursesStringWidget.cxx

@@ -64,7 +64,8 @@ void cmCursesStringWidget::OnType(int& key, cmCursesMainForm* fm,
 bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
                                        WINDOW* w)
 {
-  int x, y;
+  int x;
+  int y;
 
   FORM* form = fm->GetForm();
   // when not in edit mode, edit mode is entered by pressing enter or i (vim
@@ -179,7 +180,8 @@ const char* cmCursesStringWidget::GetValue()
 
 bool cmCursesStringWidget::PrintKeys()
 {
-  int x, y;
+  int x;
+  int y;
   getmaxyx(stdscr, y, x);
   if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
     return false;

+ 2 - 1
Source/QtDialog/QCMakeCacheView.cxx

@@ -210,7 +210,8 @@ void QCMakeCacheModel::clear()
 
 void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
 {
-  QSet<QCMakeProperty> newProps, newProps2;
+  QSet<QCMakeProperty> newProps;
+  QSet<QCMakeProperty> newProps2;
 
   if (this->ShowNewProperties) {
     newProps = props.toSet();

+ 10 - 2
Source/cmAddCustomCommandCommand.cxx

@@ -33,10 +33,18 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
   }
 
   cmMakefile& mf = status.GetMakefile();
-  std::string source, target, main_dependency, working, depfile, job_pool;
+  std::string source;
+  std::string target;
+  std::string main_dependency;
+  std::string working;
+  std::string depfile;
+  std::string job_pool;
   std::string comment_buffer;
   const char* comment = nullptr;
-  std::vector<std::string> depends, outputs, output, byproducts;
+  std::vector<std::string> depends;
+  std::vector<std::string> outputs;
+  std::vector<std::string> output;
+  std::vector<std::string> byproducts;
   bool verbatim = false;
   bool append = false;
   bool uses_terminal = false;

+ 2 - 1
Source/cmAddCustomTargetCommand.cxx

@@ -43,7 +43,8 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
   cmCustomCommandLines commandLines;
 
   // Accumulate dependencies.
-  std::vector<std::string> depends, byproducts;
+  std::vector<std::string> depends;
+  std::vector<std::string> byproducts;
   std::string working_directory;
   bool verbatim = false;
   bool uses_terminal = false;

+ 2 - 1
Source/cmBinUtilsMacOSMachOLinker.cxx

@@ -59,7 +59,8 @@ bool cmBinUtilsMacOSMachOLinker::ScanDependencies(
 bool cmBinUtilsMacOSMachOLinker::ScanDependencies(
   std::string const& file, std::string const& executablePath)
 {
-  std::vector<std::string> libs, rpaths;
+  std::vector<std::string> libs;
+  std::vector<std::string> rpaths;
   if (!this->Tool->GetFileInfo(file, libs, rpaths)) {
     return false;
   }

+ 3 - 1
Source/cmFileCommand.cxx

@@ -2759,7 +2759,9 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
     return false;
   }
 
-  std::vector<std::string> deps, unresolvedDeps, conflictingDeps;
+  std::vector<std::string> deps;
+  std::vector<std::string> unresolvedDeps;
+  std::vector<std::string> conflictingDeps;
   for (auto const& val : archive.GetResolvedPaths()) {
     bool unique = true;
     auto it = val.second.begin();

+ 4 - 2
Source/cmFileTimeCache.cxx

@@ -38,7 +38,8 @@ bool cmFileTimeCache::Compare(std::string const& f1, std::string const& f2,
                               int* result)
 {
   // Get the modification time for each file.
-  cmFileTime ft1, ft2;
+  cmFileTime ft1;
+  cmFileTime ft2;
   if (this->Load(f1, ft1) && this->Load(f2, ft2)) {
     // Compare the two modification times.
     *result = ft1.Compare(ft2);
@@ -52,7 +53,8 @@ bool cmFileTimeCache::Compare(std::string const& f1, std::string const& f2,
 bool cmFileTimeCache::DifferS(std::string const& f1, std::string const& f2)
 {
   // Get the modification time for each file.
-  cmFileTime ft1, ft2;
+  cmFileTime ft1;
+  cmFileTime ft2;
   if (this->Load(f1, ft1) && this->Load(f2, ft2)) {
     // Compare the two modification times.
     return ft1.DifferS(ft2);

+ 6 - 3
Source/cmGeneratorExpressionNode.cxx

@@ -275,7 +275,8 @@ static const struct InListNode : public cmGeneratorExpressionNode
     const GeneratorExpressionContent* /*content*/,
     cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
   {
-    std::vector<std::string> values, checkValues;
+    std::vector<std::string> values;
+    std::vector<std::string> checkValues;
     bool check = false;
     switch (context->LG->GetPolicyStatus(cmPolicies::CMP0085)) {
       case cmPolicies::WARN:
@@ -347,7 +348,8 @@ static const struct FilterNode : public cmGeneratorExpressionNode
       return {};
     }
 
-    std::vector<std::string> values, result;
+    std::vector<std::string> values;
+    std::vector<std::string> result;
     cmExpandList(parameters.front(), values, true);
 
     std::copy_if(values.cbegin(), values.cend(), std::back_inserter(result),
@@ -1109,7 +1111,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
     static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
 
     cmGeneratorTarget const* target = nullptr;
-    std::string targetName, propertyName;
+    std::string targetName;
+    std::string propertyName;
 
     if (parameters.size() == 2) {
       targetName = parameters[0];

+ 6 - 2
Source/cmGeneratorTarget.cxx

@@ -526,7 +526,9 @@ std::string cmGeneratorTarget::GetFilePrefix(
     return prefix ? prefix : std::string();
   }
 
-  std::string prefix, suffix, base;
+  std::string prefix;
+  std::string suffix;
+  std::string base;
   this->GetFullNameInternal(config, artifact, prefix, base, suffix);
   return prefix;
 }
@@ -539,7 +541,9 @@ std::string cmGeneratorTarget::GetFileSuffix(
     return suffix ? suffix : std::string();
   }
 
-  std::string prefix, suffix, base;
+  std::string prefix;
+  std::string suffix;
+  std::string base;
   this->GetFullNameInternal(config, artifact, prefix, base, suffix);
   return suffix;
 }

+ 2 - 1
Source/cmGraphVizWriter.cxx

@@ -74,7 +74,8 @@ std::map<std::string, LinkLibraryScopeType> getScopedLinkLibrariesFromTarget(
 {
   char sep = ';';
   std::map<std::string, LinkLibraryScopeType> tokens;
-  size_t start = 0, end = 0;
+  size_t start = 0;
+  size_t end = 0;
 
   const char* pInterfaceLinkLibraries =
     Target->GetProperty("INTERFACE_LINK_LIBRARIES");

+ 2 - 1
Source/cmInstallTargetGenerator.cxx

@@ -688,7 +688,8 @@ void cmInstallTargetGenerator::AddChrpathPatchRule(
     std::string installNameTool =
       mf->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
 
-    std::vector<std::string> oldRuntimeDirs, newRuntimeDirs;
+    std::vector<std::string> oldRuntimeDirs;
+    std::vector<std::string> newRuntimeDirs;
     cli->GetRPath(oldRuntimeDirs, false);
     cli->GetRPath(newRuntimeDirs, true);
 

+ 9 - 4
Source/cmListCommand.cxx

@@ -695,7 +695,8 @@ public:
     }
 
     this->Indexes.resize(size);
-    auto start = this->Start, step = this->Step;
+    auto start = this->Start;
+    auto step = this->Step;
     std::generate(this->Indexes.begin(), this->Indexes.end(),
                   [&start, step]() -> int {
                     auto r = start;
@@ -919,8 +920,10 @@ bool cmListCommand::HandleTransformCommand(
     }
   }
 
-  const std::string REGEX{ "REGEX" }, AT{ "AT" }, FOR{ "FOR" },
-    OUTPUT_VARIABLE{ "OUTPUT_VARIABLE" };
+  const std::string REGEX{ "REGEX" };
+  const std::string AT{ "AT" };
+  const std::string FOR{ "FOR" };
+  const std::string OUTPUT_VARIABLE{ "OUTPUT_VARIABLE" };
 
   // handle optional arguments
   while (args.size() > index) {
@@ -997,7 +1000,9 @@ bool cmListCommand::HandleTransformCommand(
         return false;
       }
 
-      int start = 0, stop = 0, step = 1;
+      int start = 0;
+      int stop = 0;
+      int step = 1;
       bool valid = true;
       try {
         std::size_t pos;

+ 2 - 2
Source/cmLocalGenerator.cxx

@@ -1036,8 +1036,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
   // Support putting all the in-project include directories first if
   // it is requested by the project.
   if (this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) {
-    std::string const &topSourceDir = this->GetState()->GetSourceDirectory(),
-                      &topBinaryDir = this->GetState()->GetBinaryDirectory();
+    std::string const& topSourceDir = this->GetState()->GetSourceDirectory();
+    std::string const& topBinaryDir = this->GetState()->GetBinaryDirectory();
     for (BT<std::string> const& udr : userDirs) {
       // Emit this directory only if it is a subdirectory of the
       // top-level source or binary tree.

+ 2 - 1
Source/cmLocalNinjaGenerator.cxx

@@ -556,7 +556,8 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
     ++j;
 
     for (; j != i->second.end(); ++j) {
-      std::vector<std::string> jDeps, depsIntersection;
+      std::vector<std::string> jDeps;
+      std::vector<std::string> depsIntersection;
       this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure(*j, jDeps);
       std::sort(jDeps.begin(), jDeps.end());
       std::set_intersection(ccTargetDeps.begin(), ccTargetDeps.end(),

+ 2 - 1
Source/cmNinjaNormalTargetGenerator.cxx

@@ -967,7 +967,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     &gt->GetPostBuildCommands()
   };
 
-  std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
+  std::vector<std::string> preLinkCmdLines;
+  std::vector<std::string> postBuildCmdLines;
   std::vector<std::string>* cmdLineLists[3] = { &preLinkCmdLines,
                                                 &preLinkCmdLines,
                                                 &postBuildCmdLines };

+ 2 - 1
Source/cmNinjaUtilityTargetGenerator.cxx

@@ -43,7 +43,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
 
   cmNinjaBuild phonyBuild("phony");
   std::vector<std::string> commands;
-  cmNinjaDeps deps, util_outputs(1, utilCommandName);
+  cmNinjaDeps deps;
+  cmNinjaDeps util_outputs(1, utilCommandName);
 
   bool uses_terminal = false;
   {

+ 2 - 2
Source/cmParseArgumentsCommand.cxx

@@ -117,8 +117,8 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
     return false;
   }
 
-  std::vector<std::string>::const_iterator argIter = args.begin(),
-                                           argEnd = args.end();
+  std::vector<std::string>::const_iterator argIter = args.begin();
+  std::vector<std::string>::const_iterator argEnd = args.end();
   bool parseFromArgV = false;
   unsigned long argvStart = 0;
   if (*argIter == "PARSE_ARGV") {

+ 4 - 2
Source/cmQtAutoMocUic.cxx

@@ -1762,7 +1762,8 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
     // Headers
     {
       // Get file lists
-      const char *keyFiles = "AM_HEADERS", *keyFlags = "AM_HEADERS_FLAGS";
+      const char* keyFiles = "AM_HEADERS";
+      const char* keyFlags = "AM_HEADERS_FLAGS";
       std::vector<std::string> files = InfoGetList(keyFiles);
       std::vector<std::string> flags = InfoGetList(keyFlags);
       std::vector<std::string> builds;
@@ -1797,7 +1798,8 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
 
     // Sources
     {
-      const char *keyFiles = "AM_SOURCES", *keyFlags = "AM_SOURCES_FLAGS";
+      const char* keyFiles = "AM_SOURCES";
+      const char* keyFlags = "AM_SOURCES_FLAGS";
       std::vector<std::string> files = InfoGetList(keyFiles);
       std::vector<std::string> flags = InfoGetList(keyFlags);
       if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) {

+ 2 - 1
Source/cmSystemTools.cxx

@@ -2375,7 +2375,8 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
 {
   const char* endl = lhss;
   const char* endr = rhss;
-  unsigned long lhs, rhs;
+  unsigned long lhs;
+  unsigned long rhs;
 
   while (((*endl >= '0') && (*endl <= '9')) ||
          ((*endr >= '0') && (*endr <= '9'))) {

+ 2 - 1
Source/cmUseMangledMesaCommand.cxx

@@ -51,7 +51,8 @@ bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
 void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(
   const std::string& source, const std::string& outdir)
 {
-  std::string dir, file;
+  std::string dir;
+  std::string file;
   cmSystemTools::SplitProgramPath(source, dir, file);
   std::string outFile = outdir;
   outFile += "/";

+ 4 - 2
Source/cmake.cxx

@@ -296,7 +296,8 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
           return false;
         }
       }
-      std::string var, value;
+      std::string var;
+      std::string value;
       cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED;
       if (cmState::ParseCacheEntry(entry, var, value, type)) {
         // The value is transformed if it is a filepath for example, so
@@ -2092,7 +2093,8 @@ void cmake::UpdateConversionPathTable()
                            ". CMake can not open file.");
       cmSystemTools::ReportLastSystemError("CMake can not open file.");
     } else {
-      std::string a, b;
+      std::string a;
+      std::string b;
       while (!table.eof()) {
         // two entries per line
         table >> a;

+ 4 - 2
Source/cmcmd.cxx

@@ -765,8 +765,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
     if (args[1] == "time" && args.size() > 2) {
       std::vector<std::string> command(args.begin() + 2, args.end());
 
-      clock_t clock_start, clock_finish;
-      time_t time_start, time_finish;
+      clock_t clock_start;
+      clock_t clock_finish;
+      time_t time_start;
+      time_t time_finish;
 
       time(&time_start);
       clock_start = clock();