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

clang-tidy: apply readability-redundant-string-init fixes

Daniel Pfeifer 8 лет назад
Родитель
Сommit
a74e689348

+ 6 - 6
Source/CTest/cmCTestCoverageHandler.cxx

@@ -977,7 +977,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
 
   std::set<std::string> missingFiles;
 
-  std::string actualSourceFile = "";
+  std::string actualSourceFile;
   cmCTestOptionalLog(
     this->CTest, HANDLER_OUTPUT,
     "   Processing coverage (each . represents one file):" << std::endl,
@@ -1006,8 +1006,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                        command << std::endl, this->Quiet);
 
-    std::string output = "";
-    std::string errors = "";
+    std::string output;
+    std::string errors;
     int retVal = 0;
     *cont->OFS << "* Run coverage for: " << fileDir << std::endl;
     *cont->OFS << "  Command: " << command << std::endl;
@@ -1344,7 +1344,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
 
   std::set<std::string> missingFiles;
 
-  std::string actualSourceFile = "";
+  std::string actualSourceFile;
   cmCTestOptionalLog(
     this->CTest, HANDLER_OUTPUT,
     "   Processing coverage (each . represents one file):" << std::endl,
@@ -1371,8 +1371,8 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                        command << std::endl, this->Quiet);
 
-    std::string output = "";
-    std::string errors = "";
+    std::string output;
+    std::string errors;
     int retVal = 0;
     *cont->OFS << "* Run coverage for: " << fileDir << std::endl;
     *cont->OFS << "  Command: " << command << std::endl;

+ 1 - 1
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -256,7 +256,7 @@ void cmCTestMultiProcessHandler::StartNextTests()
   bool allTestsFailedTestLoadCheck = false;
   bool usedFakeLoadForTesting = false;
   size_t minProcessorsRequired = this->ParallelLevel;
-  std::string testWithMinProcessors = "";
+  std::string testWithMinProcessors;
 
   cmsys::SystemInformation info;
 

+ 3 - 3
Source/CTest/cmCTestSubmitHandler.cxx

@@ -388,7 +388,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
       *this->LogFile << "\tUpload file: " << local_file << " to "
                      << remote_file << std::endl;
 
-      std::string ofile = "";
+      std::string ofile;
       for (kk = 0; kk < remote_file.size(); kk++) {
         char c = remote_file[kk];
         char hexCh[4] = { 0, 0, 0, 0 };
@@ -582,7 +582,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
 void cmCTestSubmitHandler::ParseResponse(
   cmCTestSubmitHandlerVectorOfChar chunk)
 {
-  std::string output = "";
+  std::string output;
   output.append(chunk.begin(), chunk.end());
 
   if (output.find("<cdash") != output.npos) {
@@ -662,7 +662,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
       ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
 
       std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file);
-      std::string ofile = "";
+      std::string ofile;
       std::string::iterator kk;
       for (kk = rfile.begin(); kk < rfile.end(); ++kk) {
         char c = *kk;

+ 2 - 2
Source/CTest/cmCTestTestHandler.cxx

@@ -718,7 +718,7 @@ void cmCTestTestHandler::ComputeTestList()
   // Now create a final list of tests to run
   int cnt = 0;
   inREcnt = 0;
-  std::string last_directory = "";
+  std::string last_directory;
   ListOfTests finalList;
   for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
     cnt++;
@@ -1649,7 +1649,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
   int numFiles =
     static_cast<int>(cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
   std::string pattern = "LastTestsFailed";
-  std::string logName = "";
+  std::string logName;
 
   for (int i = 0; i < numFiles; ++i) {
     std::string fileName = directory.GetFile(i);

+ 1 - 1
Source/CTest/cmParseCoberturaCoverage.cxx

@@ -54,7 +54,7 @@ protected:
   void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
   {
     std::string FoundSource;
-    std::string finalpath = "";
+    std::string finalpath;
     if (name == "source") {
       this->InSource = true;
     } else if (name == "sources") {

+ 2 - 2
Source/cmDependsJavaParserHelper.cxx

@@ -35,7 +35,7 @@ cmDependsJavaParserHelper::~cmDependsJavaParserHelper()
 void cmDependsJavaParserHelper::CurrentClass::AddFileNamesForPrinting(
   std::vector<std::string>* files, const char* prefix, const char* sep) const
 {
-  std::string rname = "";
+  std::string rname;
   if (prefix) {
     rname += prefix;
     rname += sep;
@@ -341,7 +341,7 @@ int cmDependsJavaParserHelper::ParseFile(const char* file)
     return 0;
   }
 
-  std::string fullfile = "";
+  std::string fullfile;
   std::string line;
   while (cmSystemTools::GetLineFromStream(ifs, line)) {
     fullfile += line + "\n";

+ 1 - 1
Source/cmExportBuildAndroidMKGenerator.cxx

@@ -69,7 +69,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
   const cmGeneratorTarget* target, std::ostream& os,
   const ImportPropertyMap& properties)
 {
-  std::string config = "";
+  std::string config;
   if (!this->Configurations.empty()) {
     config = this->Configurations[0];
   }

+ 2 - 2
Source/cmExportInstallAndroidMKGenerator.cxx

@@ -67,7 +67,7 @@ void cmExportInstallAndroidMKGenerator::GenerateImportTargetCode(
   os << targetName << "\n";
   os << "LOCAL_SRC_FILES := $(_IMPORT_PREFIX)/";
   os << target->Target->GetProperty("__dest") << "/";
-  std::string config = "";
+  std::string config;
   if (!this->Configurations.empty()) {
     config = this->Configurations[0];
   }
@@ -94,7 +94,7 @@ void cmExportInstallAndroidMKGenerator::GenerateInterfaceProperties(
   cmGeneratorTarget const* target, std::ostream& os,
   const ImportPropertyMap& properties)
 {
-  std::string config = "";
+  std::string config;
   if (!this->Configurations.empty()) {
     config = this->Configurations[0];
   }

+ 1 - 1
Source/cmExtraSublimeTextGenerator.cxx

@@ -172,7 +172,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
   cmGeneratedFileStream& fout, MapSourceFileFlags& sourceFileFlags)
 {
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
-  std::string compiler = "";
+  std::string compiler;
   if (!lgs.empty()) {
     this->AppendTarget(fout, "all", lgs[0], CM_NULLPTR, make.c_str(), mf,
                        compiler.c_str(), sourceFileFlags, true);

+ 1 - 1
Source/cmFLTKWrapUICommand.cxx

@@ -71,7 +71,7 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
       commandLines.push_back(commandLine);
 
       // Add command for generating the .h and .cxx files
-      std::string no_main_dependency = "";
+      std::string no_main_dependency;
       const char* no_comment = CM_NULLPTR;
       const char* no_working_dir = CM_NULLPTR;
       this->Makefile->AddCustomCommandToOutput(

+ 1 - 1
Source/cmFileCommand.cxx

@@ -768,7 +768,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
     }
   }
 
-  std::string output = "";
+  std::string output;
   bool first = true;
   for (; i != args.end(); ++i) {
     if (*i == "LIST_DIRECTORIES") {

+ 2 - 2
Source/cmFindProgramCommand.cxx

@@ -116,7 +116,7 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn,
 
 std::string cmFindProgramCommand::FindProgram()
 {
-  std::string program = "";
+  std::string program;
 
   if (this->SearchAppBundleFirst || this->SearchAppBundleOnly) {
     program = FindAppBundle();
@@ -214,7 +214,7 @@ std::string cmFindProgramCommand::FindAppBundle()
 
 std::string cmFindProgramCommand::GetBundleExecutable(std::string bundlePath)
 {
-  std::string executable = "";
+  std::string executable;
   (void)bundlePath;
 #if defined(__APPLE__)
   // Started with an example on developer.apple.com about finding bundles

+ 2 - 2
Source/cmMakefile.cxx

@@ -961,7 +961,7 @@ void cmMakefile::AddCustomCommandOldStyle(
                                           commandLines, comment, CM_NULLPTR);
     } else {
       // The source may not be a real file.  Do not use a main dependency.
-      std::string no_main_dependency = "";
+      std::string no_main_dependency;
       std::vector<std::string> depends2 = depends;
       depends2.push_back(source);
       sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
@@ -1051,7 +1051,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
     force += utilityName;
     std::vector<std::string> forced;
     forced.push_back(force);
-    std::string no_main_dependency = "";
+    std::string no_main_dependency;
     bool no_replace = false;
     this->AddCustomCommandToOutput(
       forced, byproducts, depends, no_main_dependency, commandLines, comment,

+ 1 - 1
Source/cmNinjaTargetGenerator.cxx

@@ -495,7 +495,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
       this->GetMakefile()->GetRequiredDefinition(ppVar);
 
     // Explicit preprocessing always uses a depfile.
-    std::string const ppDeptype = ""; // no deps= for multiple outputs
+    std::string const ppDeptype; // no deps= for multiple outputs
     std::string const ppDepfile = "$DEP_FILE";
 
     cmRulePlaceholderExpander::RuleVariables ppVars;

+ 1 - 1
Source/cmQTWrapCPPCommand.cxx

@@ -77,7 +77,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
       depends.push_back(moc_exe);
       depends.push_back(hname);
 
-      std::string no_main_dependency = "";
+      std::string no_main_dependency;
       const char* no_working_dir = CM_NULLPTR;
       this->Makefile->AddCustomCommandToOutput(
         newName, depends, no_main_dependency, commandLines, "Qt Wrapped File",

+ 1 - 1
Source/cmQTWrapUICommand.cxx

@@ -108,7 +108,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
 
       std::vector<std::string> depends;
       depends.push_back(uiName);
-      std::string no_main_dependency = "";
+      std::string no_main_dependency;
       const char* no_comment = CM_NULLPTR;
       const char* no_working_dir = CM_NULLPTR;
       this->Makefile->AddCustomCommandToOutput(

+ 1 - 1
Source/cmQtAutoGenerators.cxx

@@ -110,7 +110,7 @@ cmQtAutoGenerators::cmQtAutoGenerators()
   , GenerateAll(false)
 {
 
-  std::string colorEnv = "";
+  std::string colorEnv;
   cmsys::SystemTools::GetEnv("COLOR", colorEnv);
   if (!colorEnv.empty()) {
     if (cmSystemTools::IsOn(colorEnv.c_str())) {

+ 1 - 1
Source/cmStringCommand.cxx

@@ -150,7 +150,7 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args)
   }
   std::string::size_type cc;
   std::string outvar = args[args.size() - 1];
-  std::string output = "";
+  std::string output;
   for (cc = 1; cc < args.size() - 1; cc++) {
     int ch = atoi(args[cc].c_str());
     if (ch > 0 && ch < 256) {

+ 1 - 1
Source/cmTimestamp.cxx

@@ -82,7 +82,7 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const
 #else
   // From Linux timegm() manpage.
 
-  std::string tz_old = "";
+  std::string tz_old;
   cmSystemTools::GetEnv("TZ", tz_old);
   tz_old = "TZ=" + tz_old;