cmGeneratedFileStream: clang-tidy applied to remove redundant `c_str` calls

After changing the ``cmGeneratedFileStream`` methods to accept
``std::string const&`` instead of ``const char*`` we don't
need to call ``std::string::c_str`` anymore when passing
a ``std::string`` to a ``cmGeneratedFileStream`` method.

This patch removes all redundant ``std::string::c_str``
calls when passing a string to a ``cmGeneratedFileStream`` method.

It was generated by building CMake with clang-tidy enabled using
the following options:

-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy-4.0;-checks=-*,readability-redundant-string-cstr;-fix;-fix-errors
This commit is contained in:
Sebastian Holtermann
2018-08-07 15:01:25 +02:00
parent a688defcc6
commit b6802cd506
37 changed files with 87 additions and 93 deletions
+2 -2
View File
@@ -90,7 +90,7 @@ int cmCPackIFWGenerator::PackageFiles()
ifwCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
cmGeneratedFileStream ofs(ifwTmpFile);
ofs << "# Run command: " << ifwCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
@@ -203,7 +203,7 @@ int cmCPackIFWGenerator::PackageFiles()
ifwCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
cmGeneratedFileStream ofs(ifwTmpFile);
ofs << "# Run command: " << ifwCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
+1 -1
View File
@@ -306,7 +306,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
}
// Output stream
cmGeneratedFileStream fout((this->Directory + "/config/config.xml").data());
cmGeneratedFileStream fout(this->Directory + "/config/config.xml");
cmXMLWriter xout(fout);
xout.StartDocument();
+1 -1
View File
@@ -528,7 +528,7 @@ void cmCPackIFWPackage::GeneratePackageFile()
}
// Output stream
cmGeneratedFileStream fout((this->Directory + "/meta/package.xml").data());
cmGeneratedFileStream fout(this->Directory + "/meta/package.xml");
cmXMLWriter xout(fout);
xout.StartDocument();
+1 -1
View File
@@ -183,7 +183,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml()
this->Directory + "/repository/UpdatesPatch.xml";
// Output stream
cmGeneratedFileStream fout(updatesPatchXml.data());
cmGeneratedFileStream fout(updatesPatchXml);
cmXMLWriter xout(fout);
xout.StartDocument();
+1 -1
View File
@@ -103,7 +103,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
*/
#define DECLARE_AND_OPEN_ARCHIVE(filename, archive) \
cmGeneratedFileStream gf; \
gf.Open((filename).c_str(), false, true); \
gf.Open((filename), false, true); \
if (!GenerateHeader(&gf)) { \
cmCPackLogger(cmCPackLog::LOG_ERROR, \
"Problem to generate Header for archive <" \
+9 -9
View File
@@ -238,7 +238,7 @@ int cmCPackDebGenerator::createDeb()
const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
const std::string dbfilename = strGenWDIR + "/debian-binary";
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(dbfilename.c_str());
cmGeneratedFileStream out(dbfilename);
out << "2.0";
out << std::endl; // required for valid debian package
}
@@ -287,7 +287,7 @@ int cmCPackDebGenerator::createDeb()
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(ctlfilename.c_str());
cmGeneratedFileStream out(ctlfilename);
out << "Package: " << debian_pkg_name << "\n";
out << "Version: " << debian_pkg_version << "\n";
out << "Section: " << debian_pkg_section << "\n";
@@ -347,7 +347,7 @@ int cmCPackDebGenerator::createDeb()
const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
debian_pkg_shlibs && *debian_pkg_shlibs;
if (gen_shibs) {
cmGeneratedFileStream out(shlibsfilename.c_str());
cmGeneratedFileStream out(shlibsfilename);
out << debian_pkg_shlibs;
out << std::endl;
}
@@ -355,7 +355,7 @@ int cmCPackDebGenerator::createDeb()
const std::string postinst = strGenWDIR + "/postinst";
const std::string postrm = strGenWDIR + "/postrm";
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
cmGeneratedFileStream out(postinst.c_str());
cmGeneratedFileStream out(postinst);
out << "#!/bin/sh\n\n"
"set -e\n\n"
"if [ \"$1\" = \"configure\" ]; then\n"
@@ -363,7 +363,7 @@ int cmCPackDebGenerator::createDeb()
"fi\n";
}
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
cmGeneratedFileStream out(postrm.c_str());
cmGeneratedFileStream out(postrm);
out << "#!/bin/sh\n\n"
"set -e\n\n"
"if [ \"$1\" = \"remove\" ]; then\n"
@@ -412,7 +412,7 @@ int cmCPackDebGenerator::createDeb()
// atomic file generation for data.tar
{
cmGeneratedFileStream fileStream_data_tar;
fileStream_data_tar.Open(filename_data_tar.c_str(), false, true);
fileStream_data_tar.Open(filename_data_tar, false, true);
if (!fileStream_data_tar) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error opening the file \""
@@ -493,7 +493,7 @@ int cmCPackDebGenerator::createDeb()
std::string md5filename = strGenWDIR + "/md5sums";
{
// the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(md5filename.c_str());
cmGeneratedFileStream out(md5filename);
std::string topLevelWithTrailingSlash =
this->GetOption("CPACK_TEMPORARY_DIRECTORY");
@@ -528,7 +528,7 @@ int cmCPackDebGenerator::createDeb()
// atomic file generation for control.tar
{
cmGeneratedFileStream fileStream_control_tar;
fileStream_control_tar.Open(filename_control_tar.c_str(), false, true);
fileStream_control_tar.Open(filename_control_tar, false, true);
if (!fileStream_control_tar) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error opening the file \"" << filename_control_tar
@@ -662,7 +662,7 @@ int cmCPackDebGenerator::createDeb()
std::string const outputPath = outputDir + "/" + outputName;
std::string const tlDir = strGenWDIR + "/";
cmGeneratedFileStream debStream;
debStream.Open(outputPath.c_str(), false, true);
debStream.Open(outputPath, false, true);
cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd");
// uid/gid should be the one of the root user, and this root user has
+2 -2
View File
@@ -288,7 +288,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/InstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << ic << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
@@ -660,7 +660,7 @@ int cmCPackGenerator::RunPreinstallTarget(
if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/PreinstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << buildCommand << std::endl
<< "# Directory: " << installDirectory << std::endl
<< "# Output:" << std::endl
+4 -4
View File
@@ -305,7 +305,7 @@ int cmCPackNSISGenerator::PackageFiles()
nsisCmd.c_str(), &output, &output, &retVal, nullptr,
this->GeneratorVerbose, cmDuration::zero());
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << nsisCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
@@ -416,7 +416,7 @@ int cmCPackNSISGenerator::InitializeInternal()
const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
std::string tmpFile = topDir ? topDir : ".";
tmpFile += "/NSISOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << nsisCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
@@ -726,7 +726,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
unsigned long totalSize = 0;
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(zipListFileName.c_str());
cmGeneratedFileStream out(zipListFileName);
for (std::string const& file : component->Files) {
if (needQuotesInFile) {
out << "\"";
@@ -754,7 +754,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
if (!res || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/CompressZip.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << cmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
+2 -2
View File
@@ -742,7 +742,7 @@ void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
// Give some testing configuration information to the launcher.
std::string fname = this->Handler->CTestLaunchDir;
fname += "/CTestLaunchConfig.cmake";
cmGeneratedFileStream fout(fname.c_str());
cmGeneratedFileStream fout(fname);
std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
}
@@ -757,7 +757,7 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
fname += "/Custom";
fname += purpose;
fname += ".txt";
cmGeneratedFileStream fout(fname.c_str());
cmGeneratedFileStream fout(fname);
for (std::string const& m : matchers) {
fout << m << "\n";
}
+1 -1
View File
@@ -345,7 +345,7 @@ void cmCTestLaunch::WriteXML()
logXML += ".xml";
// Use cmGeneratedFileStream to atomically create the report file.
cmGeneratedFileStream fxml(logXML.c_str());
cmGeneratedFileStream fxml(logXML);
cmXMLWriter xml(fxml, 2);
cmXMLElement e2(xml, "Failure");
e2.Attribute("type", this->IsError() ? "Error" : "Warning");
+2 -2
View File
@@ -792,7 +792,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Write CMake output to file: " << cmakeOutputFile
<< std::endl);
cmGeneratedFileStream fout(cmakeOutputFile.c_str());
cmGeneratedFileStream fout(cmakeOutputFile);
if (fout) {
fout << output.c_str();
} else {
@@ -856,7 +856,7 @@ bool cmCTestScriptHandler::WriteInitialCache(const char* directory,
{
std::string cacheFile = directory;
cacheFile += "/CMakeCache.txt";
cmGeneratedFileStream fout(cacheFile.c_str());
cmGeneratedFileStream fout(cacheFile);
if (!fout) {
return false;
}
+1 -1
View File
@@ -121,7 +121,7 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
// Log startup actions.
std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log";
cmGeneratedFileStream ofs(startLogFile.c_str());
cmGeneratedFileStream ofs(startLogFile);
if (!ofs) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create log file: LastStart.log" << std::endl);
+1 -1
View File
@@ -818,7 +818,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name,
}
}
std::string filename = testingDir + "/" + name;
stream.Open(filename.c_str());
stream.Open(filename);
if (!stream) {
cmCTestLog(this, ERROR_MESSAGE,
"Problem opening file: " << filename << std::endl);
+1 -1
View File
@@ -234,7 +234,7 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
{
std::string cacheFile = path;
cacheFile += "/CMakeCache.txt";
cmGeneratedFileStream fout(cacheFile.c_str());
cmGeneratedFileStream fout(cacheFile);
fout.SetCopyIfDifferent(true);
if (!fout) {
cmSystemTools::Error("Unable to open cache file for save. ",
+2 -2
View File
@@ -178,7 +178,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
// Store the list of modules provided by this target.
std::string fiName = this->TargetDirectory;
fiName += "/fortran.internal";
cmGeneratedFileStream fiStream(fiName.c_str());
cmGeneratedFileStream fiStream(fiName);
fiStream << "# The fortran modules provided by this target.\n";
fiStream << "provides\n";
std::set<std::string> const& provides = this->Internal->TargetProvides;
@@ -190,7 +190,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
if (!provides.empty()) {
std::string fcName = this->TargetDirectory;
fcName += "/cmake_clean_Fortran.cmake";
cmGeneratedFileStream fcStream(fcName.c_str());
cmGeneratedFileStream fcStream(fcName);
fcStream << "# Remove fortran modules provided by this target.\n";
fcStream << "FILE(REMOVE";
std::string currentBinDir =
+1 -1
View File
@@ -339,7 +339,7 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
fname += "/";
fname += hash;
if (!cmSystemTools::FileExists(fname)) {
cmGeneratedFileStream entry(fname.c_str(), true);
cmGeneratedFileStream entry(fname, true);
if (entry) {
entry << content << "\n";
} else {
+1 -1
View File
@@ -75,7 +75,7 @@ bool cmExportFileGenerator::GenerateImportFile()
} else {
// Generate atomically and with copy-if-different.
std::unique_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
new cmGeneratedFileStream(this->MainImportFile, true));
ap->SetCopyIfDifferent(true);
foutPtr = std::move(ap);
}
+1 -1
View File
@@ -288,7 +288,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig(
fileName += this->FileExt;
// Open the output file to generate it.
cmGeneratedFileStream exportFileStream(fileName.c_str(), true);
cmGeneratedFileStream exportFileStream(fileName, true);
if (!exportFileStream) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
@@ -54,7 +54,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app);
} else {
std::unique_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(this->Filename.c_str(), true));
new cmGeneratedFileStream(this->Filename, true));
ap->SetCopyIfDifferent(true);
foutPtr = std::move(ap);
}
+2 -2
View File
@@ -199,7 +199,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
{
const cmMakefile* mf = lgs[0]->GetMakefile();
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -476,7 +476,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
filename += "/";
filename += target->GetName();
filename += ".objlib";
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (fout) {
/* clang-format off */
fout << "# This is a dummy file for the OBJECT library "
+3 -3
View File
@@ -77,7 +77,7 @@ void cmExtraCodeLiteGenerator::Generate()
}
}
cmGeneratedFileStream fout(workspaceFileName.c_str());
cmGeneratedFileStream fout(workspaceFileName);
cmXMLWriter xml(fout);
xml.StartDocument("utf-8");
@@ -249,7 +249,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
{
const cmMakefile* mf = lgs[0]->GetMakefile();
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -547,7 +547,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
const cmGeneratorTarget* gt, const std::string& filename)
{
const cmMakefile* mf = gt->Makefile;
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
+3 -3
View File
@@ -176,7 +176,7 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
this->GetPathBasename(this->HomeDirectory));
const std::string filename = this->HomeDirectory + "/.project";
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -261,7 +261,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
const std::string filename = this->HomeOutputDirectory + "/.project";
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -582,7 +582,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
const std::string filename = this->HomeOutputDirectory + "/.cproject";
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
+2 -2
View File
@@ -58,7 +58,7 @@ void cmExtraKateGenerator::CreateKateProjectFile(
{
std::string filename = lg->GetBinaryDirectory();
filename += "/.kateproject";
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -215,7 +215,7 @@ void cmExtraKateGenerator::CreateDummyKateProjectFile(
filename += "/";
filename += this->ProjectName;
filename += ".kateproject";
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
+1 -1
View File
@@ -91,7 +91,7 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile(
{
const cmMakefile* mf = lgs[0]->GetMakefile();
cmGeneratedFileStream fout(filename.c_str());
cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
+3 -3
View File
@@ -168,12 +168,12 @@ bool cmGeneratedFileStreamBase::Close()
// destination atomically.
if (this->Compress) {
std::string gzname = this->TempName + ".temp.gz";
if (this->CompressFile(this->TempName.c_str(), gzname.c_str())) {
this->RenameFile(gzname.c_str(), resname.c_str());
if (this->CompressFile(this->TempName, gzname)) {
this->RenameFile(gzname, resname);
}
cmSystemTools::RemoveFile(gzname);
} else {
this->RenameFile(this->TempName.c_str(), resname.c_str());
this->RenameFile(this->TempName, resname);
}
replaced = true;
@@ -85,7 +85,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(
this->Files.push_back(outputFileName);
outputFiles[outputFileName] = outputContent;
cmGeneratedFileStream fout(outputFileName.c_str());
cmGeneratedFileStream fout(outputFileName);
fout.SetCopyIfDifferent(true);
fout << outputContent;
if (fout.Close() && perm) {
+1 -1
View File
@@ -23,7 +23,7 @@ bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path)
cmSystemTools::MakeDirectory(scriptFile);
scriptFile += "/VerifyGlobs.cmake";
stampFile += "/cmake.verify_globs";
cmGeneratedFileStream verifyScriptFile(scriptFile.c_str());
cmGeneratedFileStream verifyScriptFile(scriptFile);
verifyScriptFile.SetCopyIfDifferent(true);
if (!verifyScriptFile) {
cmSystemTools::Error("Unable to open verification script file for save. ",
+5 -5
View File
@@ -2904,7 +2904,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
if (this->RuleHashes.empty()) {
cmSystemTools::RemoveFile(pfile);
} else {
cmGeneratedFileStream fout(pfile.c_str());
cmGeneratedFileStream fout(pfile);
fout << "# Hashes of file build rules.\n";
for (auto const& rh : this->RuleHashes) {
fout.write(rh.second.Data, 32);
@@ -2919,7 +2919,7 @@ void cmGlobalGenerator::WriteSummary()
std::string fname = this->CMakeInstance->GetHomeOutputDirectory();
fname += cmake::GetCMakeFilesDirectory();
fname += "/TargetDirectories.txt";
cmGeneratedFileStream fout(fname.c_str());
cmGeneratedFileStream fout(fname);
for (cmLocalGenerator* lg : this->LocalGenerators) {
const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets();
@@ -2956,7 +2956,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
Json::Value& lj_sources = lj_root["sources"] = Json::arrayValue;
cmSystemTools::MakeDirectory(dir);
cmGeneratedFileStream fout(file.c_str());
cmGeneratedFileStream fout(file);
std::vector<std::string> labels;
@@ -3030,7 +3030,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
}
}
}
cmGeneratedFileStream json_fout(json_file.c_str());
cmGeneratedFileStream json_fout(json_file);
json_fout << lj_root;
} else
#endif
@@ -3105,7 +3105,7 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile()
return true;
}
cmGeneratedFileStream file(path.c_str());
cmGeneratedFileStream file(path);
file << "# CPack properties\n";
for (auto const& i : installedFiles) {
+7 -8
View File
@@ -763,7 +763,7 @@ void cmGlobalNinjaGenerator::OpenBuildFileStream()
// Get a stream where to generate things.
if (!this->BuildFileStream) {
this->BuildFileStream = new cmGeneratedFileStream(
buildFilePath.c_str(), false, this->GetMakefileEncoding());
buildFilePath, false, this->GetMakefileEncoding());
if (!this->BuildFileStream) {
// An error message is generated by the constructor if it cannot
// open the file.
@@ -801,7 +801,7 @@ void cmGlobalNinjaGenerator::OpenRulesFileStream()
// Get a stream where to generate things.
if (!this->RulesFileStream) {
this->RulesFileStream = new cmGeneratedFileStream(
rulesFilePath.c_str(), false, this->GetMakefileEncoding());
rulesFilePath, false, this->GetMakefileEncoding());
if (!this->RulesFileStream) {
// An error message is generated by the constructor if it cannot
// open the file.
@@ -883,8 +883,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
}
// Get a stream where to generate things.
this->CompileCommandsStream =
new cmGeneratedFileStream(buildFilePath.c_str());
this->CompileCommandsStream = new cmGeneratedFileStream(buildFilePath);
*this->CompileCommandsStream << "[";
} else {
*this->CompileCommandsStream << "," << std::endl;
@@ -1700,7 +1699,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
}
{
cmGeneratedFileStream depfile(arg_dep.c_str());
cmGeneratedFileStream depfile(arg_dep);
depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":";
for (std::string const& include : info.Includes) {
depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
@@ -1723,7 +1722,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
}
}
cmGeneratedFileStream ddif(arg_ddi.c_str());
cmGeneratedFileStream ddif(arg_ddi);
ddif << ddi;
if (!ddif) {
cmSystemTools::Error("-E cmake_ninja_depends failed to write ",
@@ -1827,7 +1826,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
}
}
cmGeneratedFileStream ddf(arg_dd.c_str());
cmGeneratedFileStream ddf(arg_dd);
ddf << "ninja_dyndep_version = 1.0\n";
for (cmFortranObjectInfo const& object : objects) {
@@ -1862,7 +1861,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
// use by dependents that reference this target in linked-target-dirs.
std::string const target_mods_file =
cmSystemTools::GetFilenamePath(arg_dd) + "/FortranModules.json";
cmGeneratedFileStream tmf(target_mods_file.c_str());
cmGeneratedFileStream tmf(target_mods_file);
tmf << tm;
return true;
+5 -6
View File
@@ -147,7 +147,7 @@ void cmGlobalUnixMakefileGenerator3::Generate()
markFileName += "/";
markFileName += cmake::GetCMakeFilesDirectory();
markFileName += "/progress.marks";
cmGeneratedFileStream markFile(markFileName.c_str());
cmGeneratedFileStream markFile(markFileName);
markFile << this->CountProgressMarksInAll(lg) << "\n";
}
@@ -170,8 +170,7 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
std::string commandDatabaseName =
std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) +
"/compile_commands.json";
this->CommandDatabase =
new cmGeneratedFileStream(commandDatabaseName.c_str());
this->CommandDatabase = new cmGeneratedFileStream(commandDatabaseName);
*this->CommandDatabase << "[" << std::endl;
} else {
*this->CommandDatabase << "," << std::endl;
@@ -198,7 +197,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
this->GetCMakeInstance()->GetHomeOutputDirectory();
makefileName += cmake::GetCMakeFilesDirectory();
makefileName += "/Makefile2";
cmGeneratedFileStream makefileStream(makefileName.c_str(), false,
cmGeneratedFileStream makefileStream(makefileName, false,
this->GetMakefileEncoding());
if (!makefileStream) {
return;
@@ -270,7 +269,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
this->GetCMakeInstance()->GetHomeOutputDirectory();
cmakefileName += cmake::GetCMakeFilesDirectory();
cmakefileName += "/Makefile.cmake";
cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
cmGeneratedFileStream cmakefileStream(cmakefileName);
if (!cmakefileStream) {
return;
}
@@ -876,7 +875,7 @@ void cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
void cmGlobalUnixMakefileGenerator3::TargetProgress::WriteProgressVariables(
unsigned long total, unsigned long& current)
{
cmGeneratedFileStream fout(this->VariableFile.c_str());
cmGeneratedFileStream fout(this->VariableFile);
for (unsigned long i = 1; i <= this->NumberOfActions; ++i) {
fout << "CMAKE_PROGRESS_" << i << " = ";
if (total <= 100) {
+2 -2
View File
@@ -257,7 +257,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
currentFilename += ptr.first;
currentFilename += ".dependers";
cmGeneratedFileStream str(currentFilename.c_str());
cmGeneratedFileStream str(currentFilename);
if (!str) {
return;
}
@@ -300,7 +300,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
std::string currentFilename = fileName;
currentFilename += ".";
currentFilename += ptr.first;
cmGeneratedFileStream str(currentFilename.c_str());
cmGeneratedFileStream str(currentFilename);
if (!str) {
return;
}
+2 -2
View File
@@ -253,7 +253,7 @@ void cmLocalGenerator::GenerateTestFiles()
file += "/";
file += "CTestTestfile.cmake";
cmGeneratedFileStream fout(file.c_str());
cmGeneratedFileStream fout(file);
fout.SetCopyIfDifferent(true);
fout << "# CMake generated Testfile for " << std::endl
@@ -429,7 +429,7 @@ void cmLocalGenerator::GenerateInstallRules()
toplevel_install = 1;
}
file += "/cmake_install.cmake";
cmGeneratedFileStream fout(file.c_str());
cmGeneratedFileStream fout(file);
fout.SetCopyIfDifferent(true);
// Write the header.
+4 -6
View File
@@ -211,8 +211,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// rules may depend on this file itself.
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
cmGeneratedFileStream ruleFileStream(
ruleFileNameFull.c_str(), false,
this->GlobalGenerator->GetMakefileEncoding());
ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
if (!ruleFileStream) {
return;
}
@@ -433,7 +432,7 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
infoFileName += "/CMakeDirectoryInformation.cmake";
// Open the output file.
cmGeneratedFileStream infoFileStream(infoFileName.c_str());
cmGeneratedFileStream infoFileStream(infoFileName);
if (!infoFileStream) {
return;
}
@@ -1403,8 +1402,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
std::string ruleFileNameFull = dir;
ruleFileNameFull += "/depend.make";
cmGeneratedFileStream ruleFileStream(
ruleFileNameFull.c_str(), false,
this->GlobalGenerator->GetMakefileEncoding());
ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
ruleFileStream.SetCopyIfDifferent(true);
if (!ruleFileStream) {
return false;
@@ -1416,7 +1414,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
std::string internalRuleFileNameFull = dir;
internalRuleFileNameFull += "/depend.internal";
cmGeneratedFileStream internalRuleFileStream(
internalRuleFileNameFull.c_str(), false,
internalRuleFileNameFull, false,
this->GlobalGenerator->GetMakefileEncoding());
if (!internalRuleFileStream) {
return false;
+7 -9
View File
@@ -124,7 +124,7 @@ void cmMakefileTargetGenerator::CreateRuleFile()
// Open the rule file. This should be copy-if-different because the
// rules may depend on this file itself.
this->BuildFileStream =
new cmGeneratedFileStream(this->BuildFileNameFull.c_str(), false,
new cmGeneratedFileStream(this->BuildFileNameFull, false,
this->GlobalGenerator->GetMakefileEncoding());
this->BuildFileStream->SetCopyIfDifferent(true);
if (!this->BuildFileStream) {
@@ -237,8 +237,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
if (!cmSystemTools::FileExists(dependFileNameFull)) {
// Write an empty dependency file.
cmGeneratedFileStream depFileStream(
dependFileNameFull.c_str(), false,
this->GlobalGenerator->GetMakefileEncoding());
dependFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
depFileStream << "# Empty dependencies file for "
<< this->GeneratorTarget->GetName() << ".\n"
<< "# This may be replaced when dependencies are built."
@@ -250,7 +249,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
this->FlagFileNameFull = this->TargetBuildDirectoryFull;
this->FlagFileNameFull += "/flags.make";
this->FlagFileStream =
new cmGeneratedFileStream(this->FlagFileNameFull.c_str(), false,
new cmGeneratedFileStream(this->FlagFileNameFull, false,
this->GlobalGenerator->GetMakefileEncoding());
this->FlagFileStream->SetCopyIfDifferent(true);
if (!this->FlagFileStream) {
@@ -974,8 +973,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
this->InfoFileNameFull += "/DependInfo.cmake";
this->InfoFileNameFull =
this->LocalGenerator->ConvertToFullPath(this->InfoFileNameFull);
this->InfoFileStream =
new cmGeneratedFileStream(this->InfoFileNameFull.c_str());
this->InfoFileStream = new cmGeneratedFileStream(this->InfoFileNameFull);
this->InfoFileStream->SetCopyIfDifferent(true);
if (!*this->InfoFileStream) {
return;
@@ -1446,7 +1444,7 @@ void cmMakefileTargetGenerator::CreateLinkScript(
std::string linkScriptName = this->TargetBuildDirectoryFull;
linkScriptName += "/";
linkScriptName += name;
cmGeneratedFileStream linkScriptStream(linkScriptName.c_str());
cmGeneratedFileStream linkScriptStream(linkScriptName);
linkScriptStream.SetCopyIfDifferent(true);
for (std::string const& link_command : link_commands) {
// Do not write out empty commands or commands beginning in the
@@ -1530,7 +1528,7 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
std::string responseFileNameFull = this->TargetBuildDirectoryFull;
responseFileNameFull += "/";
responseFileNameFull += name;
cmGeneratedFileStream responseStream(responseFileNameFull.c_str());
cmGeneratedFileStream responseStream(responseFileNameFull);
responseStream.SetCopyIfDifferent(true);
responseStream << options << "\n";
@@ -1718,7 +1716,7 @@ void cmMakefileTargetGenerator::GenDefFile(
cmOutputConverter::SHELL);
real_link_commands.insert(real_link_commands.begin(), cmd);
// create a list of obj files for the -E __create_def to read
cmGeneratedFileStream fout(objlist_file.c_str());
cmGeneratedFileStream fout(objlist_file);
if (mdi->WindowsExportAllSymbols) {
for (std::string const& obj : this->Objects) {
+1 -1
View File
@@ -956,7 +956,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
preLinkCmdLines.push_back(std::move(cmd));
// create a list of obj files for the -E __create_def to read
cmGeneratedFileStream fout(obj_list_file.c_str());
cmGeneratedFileStream fout(obj_list_file);
if (mdi->WindowsExportAllSymbols) {
cmNinjaDeps objs = this->GetObjects();
+1 -1
View File
@@ -1133,7 +1133,7 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang)
}
std::string const tdin = this->GetTargetDependInfoPath(lang);
cmGeneratedFileStream tdif(tdin.c_str());
cmGeneratedFileStream tdif(tdin);
tdif << tdi;
}
+2 -2
View File
@@ -1076,7 +1076,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
cmGeneratedFileStream ofs;
ofs.SetCopyIfDifferent(true);
ofs.Open(this->AutogenInfoFile.c_str(), false, true);
ofs.Open(this->AutogenInfoFile, false, true);
if (ofs) {
// Utility lambdas
auto CWrite = [&ofs](const char* key, std::string const& value) {
@@ -1183,7 +1183,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
for (Qrc const& qrc : this->Rcc.Qrcs) {
cmGeneratedFileStream ofs;
ofs.SetCopyIfDifferent(true);
ofs.Open(qrc.InfoFile.c_str(), false, true);
ofs.Open(qrc.InfoFile, false, true);
if (ofs) {
// Utility lambdas
auto CWrite = [&ofs](const char* key, std::string const& value) {