Ver Fonte

Merge topic 'clang-tidy-8-macOS'

8588cdf3a0 clang-tidy: Fix bugprone-exception-escape diagnostic in test code
f1f57cffc7 clang-tidy: Fix performance-for-range-copy diagnostic in Xcode generator
175d8c4bf6 clang-tidy: Resolve performance-unnecessary-value-param diagnostics
7c5ec91301 cmGeneratedFileStreamBase: Optimize string construction in Close

Acked-by: Kitware Robot <[email protected]>
Merge-request: !3796
Brad King há 6 anos atrás
pai
commit
1c2c541b0c

+ 2 - 1
Source/cmGeneratedFileStream.cxx

@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 
+#include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
 #if !defined(CMAKE_BOOTSTRAP)
@@ -149,7 +150,7 @@ bool cmGeneratedFileStreamBase::Close()
     // The destination is to be replaced.  Rename the temporary to the
     // destination atomically.
     if (this->Compress) {
-      std::string gzname = this->TempName + ".temp.gz";
+      std::string gzname = cmStrCat(this->TempName, ".temp.gz");
       if (this->CompressFile(this->TempName, gzname)) {
         this->RenameFile(gzname, resname);
       }

+ 3 - 3
Source/cmGlobalXCodeGenerator.cxx

@@ -1254,7 +1254,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
         bundleFiles[tsFlags.MacFolder].push_back(sourceFile);
       }
     }
-    for (auto keySources : bundleFiles) {
+    for (auto const& keySources : bundleFiles) {
       cmXCodeObject* copyFilesBuildPhase =
         this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
       copyFilesBuildPhase->SetComment("Copy files");
@@ -1302,7 +1302,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
         bundleFiles[tsFlags.MacFolder].push_back(sourceFile);
       }
     }
-    for (auto keySources : bundleFiles) {
+    for (auto const& keySources : bundleFiles) {
       cmXCodeObject* copyFilesBuildPhase =
         this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
       copyFilesBuildPhase->SetComment("Copy files");
@@ -1433,7 +1433,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateBuildPhase(
 void cmGlobalXCodeGenerator::CreateCustomCommands(
   cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase,
   cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase,
-  std::vector<cmXCodeObject*> contentBuildPhases,
+  std::vector<cmXCodeObject*> const& contentBuildPhases,
   cmXCodeObject* frameworkBuildPhase, cmGeneratorTarget* gtgt)
 {
   std::vector<cmCustomCommand> const& prebuild = gtgt->GetPreBuildCommands();

+ 5 - 7
Source/cmGlobalXCodeGenerator.h

@@ -122,13 +122,11 @@ private:
   std::string RelativeToSource(const std::string& p);
   std::string RelativeToBinary(const std::string& p);
   std::string ConvertToRelativeForMake(std::string const& p);
-  void CreateCustomCommands(cmXCodeObject* buildPhases,
-                            cmXCodeObject* sourceBuildPhase,
-                            cmXCodeObject* headerBuildPhase,
-                            cmXCodeObject* resourceBuildPhase,
-                            std::vector<cmXCodeObject*> contentBuildPhases,
-                            cmXCodeObject* frameworkBuildPhase,
-                            cmGeneratorTarget* gtgt);
+  void CreateCustomCommands(
+    cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase,
+    cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase,
+    std::vector<cmXCodeObject*> const& contentBuildPhases,
+    cmXCodeObject* frameworkBuildPhase, cmGeneratorTarget* gtgt);
 
   std::string ComputeInfoPListLocation(cmGeneratorTarget* target);
 

+ 1 - 0
Source/cmListFileCache.cxx

@@ -326,6 +326,7 @@ cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& snapshot)
 {
 }
 
+/* NOLINTNEXTLINE(performance-unnecessary-value-param) */
 cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> parent,
                                          cmListFileContext const& lfc)
   : TopEntry(std::make_shared<Entry const>(std::move(parent), lfc))

+ 1 - 0
Source/cmVariableWatchCommand.cxx

@@ -91,6 +91,7 @@ static void deleteVariableWatchCallbackData(void* client_data)
 class FinalAction
 {
 public:
+  /* NOLINTNEXTLINE(performance-unnecessary-value-param) */
   FinalAction(cmMakefile* makefile, std::string variable)
     : Action(std::make_shared<Impl>(makefile, std::move(variable)))
   {

+ 2 - 1
Tests/CMakeLib/testUVProcessChainHelper.cxx

@@ -44,7 +44,7 @@ int main(int argc, char** argv)
   }
   if (command == "dedup") {
     // Use a nested scope to free all resources before aborting below.
-    {
+    try {
       std::string input = getStdin();
       std::set<char> seen;
       std::string output;
@@ -56,6 +56,7 @@ int main(int argc, char** argv)
       }
       std::cout << output << std::flush;
       std::cerr << "3" << std::flush;
+    } catch (...) {
     }
 
     // On Windows, the exit code of abort() is different between debug and