Просмотр исходного кода

clang-tidy: fix `readability-qualified-auto` warnings

Ben Boeckel 5 лет назад
Родитель
Сommit
cdfc4e3195
36 измененных файлов с 85 добавлено и 80 удалено
  1. 0 1
      .clang-tidy
  2. 6 6
      Source/CTest/cmCTestMultiProcessHandler.cxx
  3. 1 1
      Source/CTest/cmCTestResourceGroupsLexerHelper.cxx
  4. 5 5
      Source/CTest/cmProcess.cxx
  5. 2 2
      Source/CursesDialog/cmCursesMainForm.cxx
  6. 1 1
      Source/cmAuxSourceDirectoryCommand.cxx
  7. 1 1
      Source/cmCMakePathCommand.cxx
  8. 1 1
      Source/cmCPluginAPI.cxx
  9. 2 2
      Source/cmCacheManager.cxx
  10. 10 10
      Source/cmCacheManager.h
  11. 1 1
      Source/cmCommandArgumentParserHelper.cxx
  12. 1 1
      Source/cmExecuteProcessCommand.cxx
  13. 1 1
      Source/cmExportFileGenerator.cxx
  14. 1 1
      Source/cmExtraCodeBlocksGenerator.cxx
  15. 1 1
      Source/cmFileAPICodemodel.cxx
  16. 3 3
      Source/cmGeneratorExpressionEvaluator.cxx
  17. 2 2
      Source/cmGeneratorTarget.cxx
  18. 6 6
      Source/cmGhsMultiTargetGenerator.cxx
  19. 4 4
      Source/cmGlobalGenerator.cxx
  20. 1 1
      Source/cmGlobalGhsMultiGenerator.cxx
  21. 2 2
      Source/cmGraphVizWriter.cxx
  22. 3 2
      Source/cmLinkItemGraphVisitor.cxx
  23. 4 4
      Source/cmLocalGenerator.cxx
  24. 3 3
      Source/cmLocalUnixMakefileGenerator3.cxx
  25. 2 2
      Source/cmMakefile.cxx
  26. 1 1
      Source/cmOutputRequiredFilesCommand.cxx
  27. 1 1
      Source/cmQtAutoMocUic.cxx
  28. 2 2
      Source/cmSetPropertyCommand.cxx
  29. 1 1
      Source/cmSetSourceFilesPropertiesCommand.cxx
  30. 1 1
      Source/cmSourceFile.cxx
  31. 2 2
      Source/cmSourceFileLocation.cxx
  32. 1 1
      Source/cmState.cxx
  33. 4 0
      Source/cmStringAlgorithms.cxx
  34. 3 3
      Source/cmTarget.cxx
  35. 3 2
      Source/cmUVHandlePtr.cxx
  36. 2 2
      Source/cmcmd.cxx

+ 0 - 1
.clang-tidy

@@ -25,7 +25,6 @@ readability-*,\
 -readability-inconsistent-declaration-parameter-name,\
 -readability-magic-numbers,\
 -readability-named-parameter,\
--readability-qualified-auto,\
 -readability-redundant-access-specifiers,\
 -readability-redundant-declaration,\
 -readability-redundant-string-init,\

+ 6 - 6
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -621,7 +621,7 @@ void cmCTestMultiProcessHandler::StartNextTests()
 
 void cmCTestMultiProcessHandler::OnTestLoadRetryCB(uv_timer_t* timer)
 {
-  auto self = static_cast<cmCTestMultiProcessHandler*>(timer->data);
+  auto* self = static_cast<cmCTestMultiProcessHandler*>(timer->data);
   self->StartNextTests();
 }
 
@@ -631,7 +631,7 @@ void cmCTestMultiProcessHandler::FinishTestProcess(
   this->Completed++;
 
   int test = runner->GetIndex();
-  auto properties = runner->GetTestProperties();
+  auto* properties = runner->GetTestProperties();
 
   bool testResult = runner->EndTest(this->Completed, this->Total, started);
   if (runner->TimedOutForStopTime()) {
@@ -920,7 +920,7 @@ void cmCTestMultiProcessHandler::MarkFinished()
 static Json::Value DumpToJsonArray(const std::set<std::string>& values)
 {
   Json::Value jsonArray = Json::arrayValue;
-  for (auto& it : values) {
+  for (const auto& it : values) {
     jsonArray.append(it);
   }
   return jsonArray;
@@ -929,7 +929,7 @@ static Json::Value DumpToJsonArray(const std::set<std::string>& values)
 static Json::Value DumpToJsonArray(const std::vector<std::string>& values)
 {
   Json::Value jsonArray = Json::arrayValue;
-  for (auto& it : values) {
+  for (const auto& it : values) {
     jsonArray.append(it);
   }
   return jsonArray;
@@ -939,7 +939,7 @@ static Json::Value DumpRegExToJsonArray(
   const std::vector<std::pair<cmsys::RegularExpression, std::string>>& values)
 {
   Json::Value jsonArray = Json::arrayValue;
-  for (auto& it : values) {
+  for (const auto& it : values) {
     jsonArray.append(it.second);
   }
   return jsonArray;
@@ -949,7 +949,7 @@ static Json::Value DumpMeasurementToJsonArray(
   const std::map<std::string, std::string>& values)
 {
   Json::Value jsonArray = Json::arrayValue;
-  for (auto& it : values) {
+  for (const auto& it : values) {
     Json::Value measurement = Json::objectValue;
     measurement["measurement"] = it.first;
     measurement["value"] = it.second;

+ 1 - 1
Source/CTest/cmCTestResourceGroupsLexerHelper.cxx

@@ -17,7 +17,7 @@ bool cmCTestResourceGroupsLexerHelper::ParseString(const std::string& value)
   yyscan_t lexer;
   cmCTestResourceGroups_yylex_init_extra(this, &lexer);
 
-  auto state = cmCTestResourceGroups_yy_scan_string(value.c_str(), lexer);
+  auto* state = cmCTestResourceGroups_yy_scan_string(value.c_str(), lexer);
   int retval = cmCTestResourceGroups_yylex(lexer);
   cmCTestResourceGroups_yy_delete_buffer(state, lexer);
 

+ 5 - 5
Source/CTest/cmProcess.cxx

@@ -152,7 +152,7 @@ bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
 
 void cmProcess::StartTimer()
 {
-  auto properties = this->Runner->GetTestProperties();
+  auto* properties = this->Runner->GetTestProperties();
   auto msec =
     std::chrono::duration_cast<std::chrono::milliseconds>(this->Timeout);
 
@@ -209,7 +209,7 @@ bool cmProcess::Buffer::GetLast(std::string& line)
 void cmProcess::OnReadCB(uv_stream_t* stream, ssize_t nread,
                          const uv_buf_t* buf)
 {
-  auto self = static_cast<cmProcess*>(stream->data);
+  auto* self = static_cast<cmProcess*>(stream->data);
   self->OnRead(nread, buf);
 }
 
@@ -256,7 +256,7 @@ void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf)
 void cmProcess::OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
                              uv_buf_t* buf)
 {
-  auto self = static_cast<cmProcess*>(handle->data);
+  auto* self = static_cast<cmProcess*>(handle->data);
   self->OnAllocate(suggested_size, buf);
 }
 
@@ -272,7 +272,7 @@ void cmProcess::OnAllocate(size_t /*suggested_size*/, uv_buf_t* buf)
 
 void cmProcess::OnTimeoutCB(uv_timer_t* timer)
 {
-  auto self = static_cast<cmProcess*>(timer->data);
+  auto* self = static_cast<cmProcess*>(timer->data);
   self->OnTimeout();
 }
 
@@ -298,7 +298,7 @@ void cmProcess::OnTimeout()
 void cmProcess::OnExitCB(uv_process_t* process, int64_t exit_status,
                          int term_signal)
 {
-  auto self = static_cast<cmProcess*>(process->data);
+  auto* self = static_cast<cmProcess*>(process->data);
   self->OnExit(exit_status, term_signal);
 }
 

+ 2 - 2
Source/CursesDialog/cmCursesMainForm.cxx

@@ -405,7 +405,7 @@ void cmCursesMainForm::UpdateStatusBar(cm::optional<std::string> message)
 
     // Get the help string of the current entry
     // and add it to the help string
-    auto cmakeState = this->CMakeInstance->GetState();
+    auto* cmakeState = this->CMakeInstance->GetState();
     cmProp existingValue = cmakeState->GetCacheEntryValue(labelValue);
     if (existingValue) {
       cmProp help =
@@ -1000,7 +1000,7 @@ void cmCursesMainForm::DisplayOutputs(std::string const& newOutput)
   getmaxyx(stdscr, yi, xi);
 
   if (CurrentForm != this->LogForm.get()) {
-    auto newLogForm = new cmCursesLongMessageForm(
+    auto* newLogForm = new cmCursesLongMessageForm(
       this->Outputs, this->LastProgress.c_str(),
       cmCursesLongMessageForm::ScrollBehavior::ScrollDown);
     CurrentForm = newLogForm;

+ 1 - 1
Source/cmAuxSourceDirectoryCommand.cxx

@@ -51,7 +51,7 @@ bool cmAuxSourceDirectoryCommand(std::vector<std::string> const& args,
       if (dotpos != std::string::npos) {
         auto ext = cm::string_view(file).substr(dotpos + 1);
         // Process only source files
-        auto cm = mf.GetCMakeInstance();
+        auto* cm = mf.GetCMakeInstance();
         if (dotpos > 0 && cm->IsACLikeSourceExtension(ext)) {
           std::string fullname = cmStrCat(templateDirectory, '/', file);
           // add the file as a class file so

+ 1 - 1
Source/cmCMakePathCommand.cxx

@@ -149,7 +149,7 @@ public:
 bool getInputPath(const std::string& arg, cmExecutionStatus& status,
                   std::string& path)
 {
-  auto def = status.GetMakefile().GetDefinition(arg);
+  const auto* def = status.GetMakefile().GetDefinition(arg);
   if (def == nullptr) {
     status.SetError("undefined variable for input path.");
     return false;

+ 1 - 1
Source/cmCPluginAPI.cxx

@@ -567,7 +567,7 @@ void* CCONV cmAddSource(void* arg, void* arg2)
   sf->SourceExtension = osf->SourceExtension;
 
   // Store the proxy in the map so it can be re-used and deleted later.
-  auto value = sf.get();
+  auto* value = sf.get();
   cmCPluginAPISourceFiles[rsf] = std::move(sf);
   return value;
 }

+ 2 - 2
Source/cmCacheManager.cxx

@@ -183,7 +183,7 @@ bool cmCacheManager::ReadPropertyEntry(const std::string& entryKey,
     if (entryKey.size() > plen && *(end - plen) == '-' &&
         strcmp(end - plen + 1, p) == 0) {
       std::string key = entryKey.substr(0, entryKey.size() - plen);
-      if (auto entry = this->GetCacheEntry(key)) {
+      if (auto* entry = this->GetCacheEntry(key)) {
         // Store this property on its entry.
         entry->SetProperty(p, e.Value.c_str());
       } else {
@@ -498,7 +498,7 @@ const cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry(
 
 cmProp cmCacheManager::GetInitializedCacheValue(const std::string& key) const
 {
-  if (auto entry = this->GetCacheEntry(key)) {
+  if (const auto* entry = this->GetCacheEntry(key)) {
     if (entry->Initialized) {
       return &entry->GetValue();
     }

+ 10 - 10
Source/cmCacheManager.h

@@ -74,7 +74,7 @@ public:
 
   cmProp GetCacheEntryValue(const std::string& key) const
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (const auto* entry = this->GetCacheEntry(key)) {
       return &entry->GetValue();
     }
     return nullptr;
@@ -82,14 +82,14 @@ public:
 
   void SetCacheEntryValue(std::string const& key, std::string const& value)
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (auto* entry = this->GetCacheEntry(key)) {
       entry->SetValue(value.c_str());
     }
   }
 
   cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) const
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (const auto* entry = this->GetCacheEntry(key)) {
       return entry->GetType();
     }
     return cmStateEnums::UNINITIALIZED;
@@ -98,7 +98,7 @@ public:
   std::vector<std::string> GetCacheEntryPropertyList(
     std::string const& key) const
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (const auto* entry = this->GetCacheEntry(key)) {
       return entry->GetPropertyList();
     }
     return {};
@@ -107,7 +107,7 @@ public:
   cmProp GetCacheEntryProperty(std::string const& key,
                                std::string const& propName) const
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (const auto* entry = this->GetCacheEntry(key)) {
       return entry->GetProperty(propName);
     }
     return nullptr;
@@ -116,7 +116,7 @@ public:
   bool GetCacheEntryPropertyAsBool(std::string const& key,
                                    std::string const& propName) const
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (const auto* entry = this->GetCacheEntry(key)) {
       return entry->GetPropertyAsBool(propName);
     }
     return false;
@@ -126,7 +126,7 @@ public:
                              std::string const& propName,
                              std::string const& value)
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (auto* entry = this->GetCacheEntry(key)) {
       entry->SetProperty(propName, value.c_str());
     }
   }
@@ -134,7 +134,7 @@ public:
   void SetCacheEntryBoolProperty(std::string const& key,
                                  std::string const& propName, bool value)
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (auto* entry = this->GetCacheEntry(key)) {
       entry->SetProperty(propName, value);
     }
   }
@@ -142,7 +142,7 @@ public:
   void RemoveCacheEntryProperty(std::string const& key,
                                 std::string const& propName)
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (auto* entry = this->GetCacheEntry(key)) {
       entry->SetProperty(propName, nullptr);
     }
   }
@@ -152,7 +152,7 @@ public:
                                 std::string const& value,
                                 bool asString = false)
   {
-    if (auto entry = this->GetCacheEntry(key)) {
+    if (auto* entry = this->GetCacheEntry(key)) {
       entry->AppendProperty(propName, value, asString);
     }
   }

+ 1 - 1
Source/cmCommandArgumentParserHelper.cxx

@@ -228,7 +228,7 @@ int cmCommandArgumentParserHelper::ParseString(std::string const& str,
 
   yyscan_t yyscanner;
   cmCommandArgument_yylex_init(&yyscanner);
-  auto scanBuf = cmCommandArgument_yy_scan_string(str.c_str(), yyscanner);
+  auto* scanBuf = cmCommandArgument_yy_scan_string(str.c_str(), yyscanner);
   cmCommandArgument_yyset_extra(this, yyscanner);
   cmCommandArgument_SetupEscapes(yyscanner, this->NoEscapeMode);
   int res = cmCommandArgument_yyparse(yyscanner);

+ 1 - 1
Source/cmExecuteProcessCommand.cxx

@@ -231,7 +231,7 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
   }
   if (echo_stdout || echo_stderr) {
     std::string command;
-    for (auto& cmd : arguments.Commands) {
+    for (const auto& cmd : arguments.Commands) {
       command += "'";
       command += cmJoin(cmd, "' '");
       command += "'";

+ 1 - 1
Source/cmExportFileGenerator.cxx

@@ -1214,7 +1214,7 @@ bool cmExportFileGenerator::PopulateExportProperties(
   cmGeneratorTarget* gte, ImportPropertyMap& properties,
   std::string& errorMessage)
 {
-  auto& targetProperties = gte->Target->GetProperties();
+  const auto& targetProperties = gte->Target->GetProperties();
   if (cmProp exportProperties =
         targetProperties.GetPropertyValue("EXPORT_PROPERTIES")) {
     for (auto& prop : cmExpandedList(*exportProperties)) {

+ 1 - 1
Source/cmExtraCodeBlocksGenerator.cxx

@@ -341,7 +341,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
   all_files_map_t allFiles;
   std::vector<std::string> cFiles;
 
-  auto cm = this->GlobalGenerator->GetCMakeInstance();
+  auto* cm = this->GlobalGenerator->GetCMakeInstance();
 
   for (cmLocalGenerator* lg : lgs) {
     cmMakefile* makefile = lg->GetMakefile();

+ 1 - 1
Source/cmFileAPICodemodel.cxx

@@ -1324,7 +1324,7 @@ Json::Value Target::DumpInstallDestinations()
 {
   Json::Value destinations = Json::arrayValue;
   auto installGens = this->GT->Target->GetInstallGenerators();
-  for (auto itGen : installGens) {
+  for (auto* itGen : installGens) {
     destinations.append(this->DumpInstallDestination(itGen));
   }
   return destinations;

+ 3 - 3
Source/cmGeneratorExpressionEvaluator.cxx

@@ -31,7 +31,7 @@ std::string GeneratorExpressionContent::ProcessArbitraryContent(
 
   const auto pend = this->ParamChildren.end();
   for (; pit != pend; ++pit) {
-    for (auto& pExprEval : *pit) {
+    for (const auto& pExprEval : *pit) {
       if (node->RequiresLiteralInput()) {
         if (pExprEval->GetType() != cmGeneratorExpressionEvaluator::Text) {
           reportError(context, this->GetOriginalExpression(),
@@ -63,7 +63,7 @@ std::string GeneratorExpressionContent::Evaluate(
 {
   std::string identifier;
   {
-    for (auto& pExprEval : this->IdentifierChildren) {
+    for (const auto& pExprEval : this->IdentifierChildren) {
       identifier += pExprEval->Evaluate(context, dagChecker);
       if (context->HadError) {
         return std::string();
@@ -124,7 +124,7 @@ std::string GeneratorExpressionContent::EvaluateParameters(
         return std::string();
       }
       std::string parameter;
-      for (auto& pExprEval : *pit) {
+      for (const auto& pExprEval : *pit) {
         parameter += pExprEval->Evaluate(context, dagChecker);
         if (context->HadError) {
           return std::string();

+ 2 - 2
Source/cmGeneratorTarget.cxx

@@ -4051,7 +4051,7 @@ std::string cmGeneratorTarget::GetPchFileObject(const std::string& config,
     }
     std::string& filename = inserted.first->second;
 
-    auto pchSf = this->Makefile->GetOrCreateSource(
+    auto* pchSf = this->Makefile->GetOrCreateSource(
       pchSource, false, cmSourceFileLocationKind::Known);
 
     filename = cmStrCat(this->ObjectDirectory, this->GetObjectName(pchSf));
@@ -7360,7 +7360,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
       std::string name = this->CheckCMP0004(lib);
       if (this->GetPolicyStatusCMP0108() == cmPolicies::NEW) {
         // resolve alias name
-        auto target = this->Makefile->FindTargetToUse(name);
+        auto* target = this->Makefile->FindTargetToUse(name);
         if (target) {
           name = target->GetName();
         }

+ 6 - 6
Source/cmGhsMultiTargetGenerator.cxx

@@ -356,7 +356,7 @@ void cmGhsMultiTargetGenerator::WriteBuildEventsHelper(
     } else {
       fout << fname << "\n    :outputName=\"" << fname << ".rule\"\n";
     }
-    for (auto& byp : ccg.GetByproducts()) {
+    for (const auto& byp : ccg.GetByproducts()) {
       fout << "    :extraOutputFile=\"" << byp << "\"\n";
     }
   }
@@ -528,7 +528,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
     }
   }
 
-  for (auto& n : groupNames) {
+  for (const auto& n : groupNames) {
     groupFilesList[i] = n;
     i += 1;
   }
@@ -691,14 +691,14 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandLine(
    * the outputs is manually deleted.
    */
   bool specifyExtra = true;
-  for (auto& out : ccg.GetOutputs()) {
+  for (const auto& out : ccg.GetOutputs()) {
     fout << fname << '\n';
     fout << "    :outputName=\"" << out << "\"\n";
     if (specifyExtra) {
-      for (auto& byp : ccg.GetByproducts()) {
+      for (const auto& byp : ccg.GetByproducts()) {
         fout << "    :extraOutputFile=\"" << byp << "\"\n";
       }
-      for (auto& dep : ccg.GetDepends()) {
+      for (const auto& dep : ccg.GetDepends()) {
         fout << "    :depends=\"" << dep << "\"\n";
       }
       specifyExtra = false;
@@ -761,7 +761,7 @@ bool cmGhsMultiTargetGenerator::VisitCustomCommand(
   if (perm.find(si) == perm.end()) {
     /* set temporary mark; check if revisit*/
     if (temp.insert(si).second) {
-      for (auto& di : si->GetCustomCommand()->GetDepends()) {
+      for (const auto& di : si->GetCustomCommand()->GetDepends()) {
         cmSourceFile const* sf =
           this->GeneratorTarget->GetLocalGenerator()->GetSourceFileWithOutput(
             di);

+ 4 - 4
Source/cmGlobalGenerator.cxx

@@ -1229,7 +1229,7 @@ void cmGlobalGenerator::Configure()
     this->CMakeInstance->GetHomeOutputDirectory());
 
   auto dirMfu = cm::make_unique<cmMakefile>(this, snapshot);
-  auto dirMf = dirMfu.get();
+  auto* dirMf = dirMfu.get();
   this->Makefiles.push_back(std::move(dirMfu));
   dirMf->SetRecursionDepth(this->RecursionDepth);
   this->IndexMakefile(dirMf);
@@ -1627,8 +1627,8 @@ void cmGlobalGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt,
   }
   auto entry = insertion.first;
 
-  auto& deps = this->GetTargetDirectDepends(gt);
-  for (auto& d : deps) {
+  const auto& deps = this->GetTargetDirectDepends(gt);
+  for (const auto& d : deps) {
     this->ComputeTargetOrder(d, index);
   }
 
@@ -2928,7 +2928,7 @@ void cmGlobalGenerator::GetTargetSets(
   cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
 {
   // loop over all local generators
-  for (auto generator : generators) {
+  for (auto* generator : generators) {
     // check to make sure generator is not excluded
     if (this->IsExcluded(root, generator)) {
       continue;

+ 1 - 1
Source/cmGlobalGhsMultiGenerator.cxx

@@ -704,7 +704,7 @@ bool cmGlobalGhsMultiGenerator::ComputeTargetBuildOrder(
   std::set<cmGeneratorTarget const*> temp;
   std::set<cmGeneratorTarget const*> perm;
 
-  for (auto const ti : tgt) {
+  for (const auto* const ti : tgt) {
     bool r = this->VisitTarget(temp, perm, build, ti);
     if (r) {
       return r;

+ 2 - 2
Source/cmGraphVizWriter.cxx

@@ -282,7 +282,7 @@ void cmGraphVizWriter::ReadSettings(
 
 void cmGraphVizWriter::Write()
 {
-  auto gg = this->GlobalGenerator;
+  const auto* gg = this->GlobalGenerator;
 
   this->VisitGraph(gg->GetName());
 
@@ -303,7 +303,7 @@ void cmGraphVizWriter::Write()
   }
 
   // write global data and collect all connection data for per target graphs
-  for (auto const gt : sortedGeneratorTargets) {
+  for (const auto* const gt : sortedGeneratorTargets) {
     auto item = cmLinkItem(gt, false, gt->GetBacktrace());
     this->VisitItem(item);
   }

+ 3 - 2
Source/cmLinkItemGraphVisitor.cxx

@@ -98,7 +98,8 @@ void cmLinkItemGraphVisitor::GetDependencies(cmGeneratorTarget const& target,
                                              std::string const& config,
                                              DependencyMap& dependencies)
 {
-  auto implementationLibraries = target.GetLinkImplementationLibraries(config);
+  const auto* implementationLibraries =
+    target.GetLinkImplementationLibraries(config);
   if (implementationLibraries != nullptr) {
     for (auto const& lib : implementationLibraries->Libraries) {
       auto const& name = lib.AsStr();
@@ -106,7 +107,7 @@ void cmLinkItemGraphVisitor::GetDependencies(cmGeneratorTarget const& target,
     }
   }
 
-  auto interfaceLibraries =
+  const auto* interfaceLibraries =
     target.GetLinkInterfaceLibraries(config, &target, true);
   if (interfaceLibraries != nullptr) {
     for (auto const& lib : interfaceLibraries->Libraries) {

+ 4 - 4
Source/cmLocalGenerator.cxx

@@ -2553,7 +2553,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
         cmProp ReuseFrom =
           target->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
 
-        auto pch_sf = this->Makefile->GetOrCreateSource(
+        auto* pch_sf = this->Makefile->GetOrCreateSource(
           pchSource, false, cmSourceFileLocationKind::Known);
 
         if (!this->GetGlobalGenerator()->IsXcode()) {
@@ -2570,7 +2570,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
                 "OBJECT_OUTPUTS",
                 cmStrCat("$<$<CONFIG:", config, ">:", pchFile, ">"));
             } else {
-              auto reuseTarget =
+              auto* reuseTarget =
                 this->GlobalGenerator->FindGeneratorTarget(*ReuseFrom);
 
               if (this->Makefile->IsOn("CMAKE_PCH_COPY_COMPILE_PDB")) {
@@ -2633,7 +2633,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
 
           // Add pchHeader to source files, which will
           // be grouped as "Precompile Header File"
-          auto pchHeader_sf = this->Makefile->GetOrCreateSource(
+          auto* pchHeader_sf = this->Makefile->GetOrCreateSource(
             pchHeader, false, cmSourceFileLocationKind::Known);
           std::string err;
           pchHeader_sf->ResolveFullPath(&err);
@@ -2961,7 +2961,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
     }
 
     for (auto const& file : unity_files) {
-      auto unity = this->GetMakefile()->GetOrCreateSource(file);
+      auto* unity = this->GetMakefile()->GetOrCreateSource(file);
       target->AddSource(file, true);
       unity->SetProperty("SKIP_UNITY_BUILD_INCLUSION", "ON");
       unity->SetProperty("UNITY_SOURCE_FILE", file.c_str());

+ 3 - 3
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -151,8 +151,8 @@ void cmLocalUnixMakefileGenerator3::Generate()
     }
 
     auto& gtVisited = this->GetCommandsVisited(gt);
-    auto& deps = this->GlobalGenerator->GetTargetDirectDepends(gt);
-    for (auto& d : deps) {
+    const auto& deps = this->GlobalGenerator->GetTargetDirectDepends(gt);
+    for (const auto& d : deps) {
       // Take the union of visited source files of custom commands
       auto depVisited = this->GetCommandsVisited(d);
       gtVisited.insert(depVisited.begin(), depVisited.end());
@@ -718,7 +718,7 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsTop(
     constexpr const char* vcs_rules[] = {
       "%,v", "RCS/%", "RCS/%,v", "SCCS/s.%", "s.%",
     };
-    for (auto vcs_rule : vcs_rules) {
+    for (const auto* vcs_rule : vcs_rules) {
       std::vector<std::string> vcs_depend;
       vcs_depend.emplace_back(vcs_rule);
       this->WriteMakeRule(makefileStream, "Disable VCS-based implicit rules.",

+ 2 - 2
Source/cmMakefile.cxx

@@ -1824,7 +1824,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
 
   auto subMfu =
     cm::make_unique<cmMakefile>(this->GlobalGenerator, newSnapshot);
-  auto subMf = subMfu.get();
+  auto* subMf = subMfu.get();
   this->GetGlobalGenerator()->AddMakefile(std::move(subMfu));
 
   if (excludeFromAll) {
@@ -3370,7 +3370,7 @@ cmSourceFile* cmMakefile::GetSource(const std::string& sourceName,
 #endif
   auto sfsi = this->SourceFileSearchIndex.find(name);
   if (sfsi != this->SourceFileSearchIndex.end()) {
-    for (auto sf : sfsi->second) {
+    for (auto* sf : sfsi->second) {
       if (sf->Matches(sfl)) {
         return sf;
       }

+ 1 - 1
Source/cmOutputRequiredFilesCommand.cxx

@@ -376,7 +376,7 @@ protected:
     }
     // Didn't find an instance.  Create a new one and save it.
     auto info = cm::make_unique<cmDependInformation>();
-    auto ptr = info.get();
+    auto* ptr = info.get();
     info->FullPath = fullPath;
     info->PathOnly = cmSystemTools::GetFilenamePath(fullPath);
     info->IncludeName = file;

+ 1 - 1
Source/cmQtAutoMocUic.cxx

@@ -2708,7 +2708,7 @@ void cmQtAutoMocUicT::CreateParseJobs(SourceFileMapT const& sourceMap)
 {
   cmFileTime const parseCacheTime = this->BaseEval().ParseCacheTime;
   ParseCacheT& parseCache = this->BaseEval().ParseCache;
-  for (auto& src : sourceMap) {
+  for (const auto& src : sourceMap) {
     // Get or create the file parse data reference
     ParseCacheT::GetOrInsertT cacheEntry = parseCache.GetOrInsert(src.first);
     src.second->ParseData = std::move(cacheEntry.first);

+ 2 - 2
Source/cmSetPropertyCommand.cxx

@@ -223,7 +223,7 @@ void MakeSourceFilePathsAbsoluteIfNeeded(
 bool HandleAndValidateSourceFilePropertyGENERATED(
   cmSourceFile* sf, std::string const& propertyValue, PropertyOp op)
 {
-  auto& mf = *sf->GetLocation().GetMakefile();
+  const auto& mf = *sf->GetLocation().GetMakefile();
   auto policyStatus = mf.GetPolicyStatus(cmPolicies::CMP0118);
 
   const bool policyWARN = policyStatus == cmPolicies::WARN;
@@ -589,7 +589,7 @@ bool HandleSourceMode(cmExecutionStatus& status,
     status, files_absolute, unique_files.begin(), unique_files.end(),
     source_file_paths_should_be_absolute);
 
-  for (const auto mf : directory_makefiles) {
+  for (auto* const mf : directory_makefiles) {
     for (std::string const& name : files_absolute) {
       // Get the source file.
       if (cmSourceFile* sf = mf->GetOrCreateSource(name)) {

+ 1 - 1
Source/cmSetSourceFilesPropertiesCommand.cxx

@@ -101,7 +101,7 @@ bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
   // Now call the worker function for each directory scope represented by a
   // cmMakefile instance.
   std::string errors;
-  for (const auto mf : source_file_directory_makefiles) {
+  for (auto* const mf : source_file_directory_makefiles) {
     bool ret = RunCommandForScope(mf, files.begin(), files.end(), props_begin,
                                   args.end(), errors);
     if (!ret) {

+ 1 - 1
Source/cmSourceFile.cxx

@@ -427,7 +427,7 @@ bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
 void cmSourceFile::MarkAsGenerated()
 {
   this->IsGenerated = true;
-  auto& mf = *this->Location.GetMakefile();
+  const auto& mf = *this->Location.GetMakefile();
   mf.GetGlobalGenerator()->MarkAsGeneratedFile(this->ResolveFullPath());
 }
 

+ 2 - 2
Source/cmSourceFileLocation.cxx

@@ -98,7 +98,7 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name)
   // The global generator checks extensions of enabled languages.
   cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
   cmMakefile const* mf = this->Makefile;
-  auto cm = mf->GetCMakeInstance();
+  auto* cm = mf->GetCMakeInstance();
   if (!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
       cm->IsAKnownExtension(ext)) {
     // This is a known extension.  Use the given filename with extension.
@@ -155,7 +155,7 @@ bool cmSourceFileLocation::MatchesAmbiguousExtension(
   // disk.  One of these must match if loc refers to this source file.
   auto ext = cm::string_view(this->Name).substr(loc.Name.size() + 1);
   cmMakefile const* mf = this->Makefile;
-  auto cm = mf->GetCMakeInstance();
+  auto* cm = mf->GetCMakeInstance();
   return cm->IsAKnownExtension(ext);
 }
 

+ 1 - 1
Source/cmState.cxx

@@ -347,7 +347,7 @@ cmPropertyDefinition const* cmState::GetPropertyDefinition(
 bool cmState::IsPropertyChained(const std::string& name,
                                 cmProperty::ScopeType scope) const
 {
-  if (auto def = this->GetPropertyDefinition(name, scope)) {
+  if (const auto* def = this->GetPropertyDefinition(name, scope)) {
     return def->IsChained();
   }
   return false;

+ 4 - 0
Source/cmStringAlgorithms.cxx

@@ -11,6 +11,9 @@
 
 std::string cmTrimWhitespace(cm::string_view str)
 {
+  // XXX(clang-tidy): This declaration and the next cannot be `const auto*`
+  // because the qualification of `auto` is platform-dependent.
+  // NOLINTNEXTLINE(readability-qualified-auto)
   auto start = str.begin();
   while (start != str.end() && cmIsSpace(*start)) {
     ++start;
@@ -18,6 +21,7 @@ std::string cmTrimWhitespace(cm::string_view str)
   if (start == str.end()) {
     return std::string();
   }
+  // NOLINTNEXTLINE(readability-qualified-auto)
   auto stop = str.end() - 1;
   while (cmIsSpace(*stop)) {
     --stop;

+ 3 - 3
Source/cmTarget.cxx

@@ -1328,9 +1328,9 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
       this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
       return;
     }
-    auto reusedTarget = this->impl->Makefile->GetCMakeInstance()
-                          ->GetGlobalGenerator()
-                          ->FindTarget(value);
+    auto* reusedTarget = this->impl->Makefile->GetCMakeInstance()
+                           ->GetGlobalGenerator()
+                           ->FindTarget(value);
     if (!reusedTarget) {
       const std::string e(
         "PRECOMPILE_HEADERS_REUSE_FROM set with non existing target");

+ 3 - 2
Source/cmUVHandlePtr.cxx

@@ -59,7 +59,7 @@ uv_loop_t* uv_loop_ptr::get() const
 template <typename T>
 static void handle_default_delete(T* type_handle)
 {
-  auto handle = reinterpret_cast<uv_handle_t*>(type_handle);
+  auto* handle = reinterpret_cast<uv_handle_t*>(type_handle);
   if (handle) {
     assert(!uv_is_closing(handle));
     if (!uv_is_closing(handle)) {
@@ -154,7 +154,8 @@ struct uv_handle_deleter<uv_async_t>
 
 void uv_async_ptr::send()
 {
-  auto deleter = std::get_deleter<uv_handle_deleter<uv_async_t>>(this->handle);
+  auto* deleter =
+    std::get_deleter<uv_handle_deleter<uv_async_t>>(this->handle);
   assert(deleter);
 
   std::lock_guard<std::mutex> lock(*deleter->handleMutex);

+ 2 - 2
Source/cmcmd.cxx

@@ -1885,7 +1885,7 @@ int cmcmd::RunPreprocessor(const std::vector<std::string>& command,
   }
   auto status = process.GetStatus();
   if (!status[0] || status[0]->ExitStatus != 0) {
-    auto errorStream = process.ErrorStream();
+    auto* errorStream = process.ErrorStream();
     if (errorStream) {
       std::cerr << errorStream->rdbuf();
     }
@@ -2013,7 +2013,7 @@ int cmcmd::RunLLVMRC(std::vector<std::string> const& args)
   }
   auto status = process.GetStatus();
   if (!status[0] || status[0]->ExitStatus != 0) {
-    auto errorStream = process.ErrorStream();
+    auto* errorStream = process.ErrorStream();
     if (errorStream) {
       std::cerr << errorStream->rdbuf();
     }