summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-03-27 11:49:44 +0000
committerKitware Robot <kwrobot@kitware.com>2020-03-27 07:51:27 -0400
commitd6119e2305f1461699c5510c5d0ff9f7df798aed (patch)
treef4d411a02732ebfc97bccff472ee0558b1c31507
parenta6611577c33538af959348b49aec817dd9649c03 (diff)
parent3fdd8db3aaf4c804dd24a59913650ad024c8343e (diff)
downloadcmake-d6119e2305f1461699c5510c5d0ff9f7df798aed.tar.gz
Merge topic 'cleanup-endls-1'
3fdd8db3aa Refactor: Avoid `std::endl` where it's not necessary (part 1) Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4513
-rw-r--r--Source/cmCacheManager.cxx92
-rw-r--r--Source/cmCallVisualStudioMacro.cxx38
-rw-r--r--Source/cmExportFileGenerator.cxx3
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx2
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx17
-rw-r--r--Source/cmLocalNinjaGenerator.cxx27
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx28
-rw-r--r--Source/cmMakefileTargetGenerator.cxx3
-rw-r--r--Source/cmWriteFileCommand.cxx2
9 files changed, 101 insertions, 111 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index c444fce2ae..31a8692a7a 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -77,7 +77,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
}
while (realbuffer[0] == '/' && realbuffer[1] == '/') {
if ((realbuffer[2] == '\\') && (realbuffer[3] == 'n')) {
- helpString += "\n";
+ helpString += '\n';
helpString += &realbuffer[4];
} else {
helpString += &realbuffer[2];
@@ -117,8 +117,8 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
}
} else {
std::ostringstream error;
- error << "Parse error in cache file " << cacheFile;
- error << " on line " << lineno << ". Offending entry: " << realbuffer;
+ error << "Parse error in cache file " << cacheFile << " on line "
+ << lineno << ". Offending entry: " << realbuffer;
cmSystemTools::Error(error.str());
}
}
@@ -217,7 +217,7 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os, CacheIterator i,
cmCacheManager::OutputKey(os, key);
os << ":INTERNAL=";
cmCacheManager::OutputValue(os, *value);
- os << "\n";
+ os << '\n';
cmCacheManager::OutputNewlineTruncationWarning(os, key, *value,
messenger);
}
@@ -268,31 +268,29 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
/* clang-format off */
fout << "# This is the CMakeCache file.\n"
- << "# For build in directory: " << currentcwd << "\n"
- << "# It was generated by CMake: "
- << cmSystemTools::GetCMakeCommand() << std::endl;
+ "# For build in directory: " << currentcwd << "\n"
+ "# It was generated by CMake: "
+ << cmSystemTools::GetCMakeCommand()
+ << "\n"
+ "# You can edit this file to change values found and used by cmake."
+ "\n"
+ "# If you do not want to change any of the values, simply exit the "
+ "editor.\n"
+ "# If you do want to change a value, simply edit, save, and exit "
+ "the editor.\n"
+ "# The syntax for the file is as follows:\n"
+ "# KEY:TYPE=VALUE\n"
+ "# KEY is the name of a variable in the cache.\n"
+ "# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!."
+ "\n"
+ "# VALUE is the current value for the KEY.\n"
+ "\n"
+ "########################\n"
+ "# EXTERNAL cache entries\n"
+ "########################\n"
+ "\n";
/* clang-format on */
- /* clang-format off */
- fout << "# You can edit this file to change values found and used by cmake."
- << std::endl
- << "# If you do not want to change any of the values, simply exit the "
- "editor." << std::endl
- << "# If you do want to change a value, simply edit, save, and exit "
- "the editor." << std::endl
- << "# The syntax for the file is as follows:\n"
- << "# KEY:TYPE=VALUE\n"
- << "# KEY is the name of a variable in the cache.\n"
- << "# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT "
- "TYPE!." << std::endl
- << "# VALUE is the current value for the KEY.\n\n";
- /* clang-format on */
-
- fout << "########################\n";
- fout << "# EXTERNAL cache entries\n";
- fout << "########################\n";
- fout << "\n";
-
for (auto const& i : this->Cache) {
CacheEntry const& ce = i.second;
cmStateEnums::CacheEntryType t = ce.Type;
@@ -309,20 +307,20 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
cmCacheManager::OutputHelpString(fout, "Missing description");
}
cmCacheManager::OutputKey(fout, i.first);
- fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
+ fout << ':' << cmState::CacheEntryTypeToString(t) << '=';
cmCacheManager::OutputValue(fout, ce.Value);
- fout << "\n";
+ fout << '\n';
cmCacheManager::OutputNewlineTruncationWarning(fout, i.first, ce.Value,
messenger);
- fout << "\n";
+ fout << '\n';
}
}
- fout << "\n";
- fout << "########################\n";
- fout << "# INTERNAL cache entries\n";
- fout << "########################\n";
- fout << "\n";
+ fout << "\n"
+ "########################\n"
+ "# INTERNAL cache entries\n"
+ "########################\n"
+ "\n";
for (cmCacheManager::CacheIterator i = this->NewIterator(); !i.IsAtEnd();
i.Next()) {
@@ -338,14 +336,14 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
cmCacheManager::OutputHelpString(fout, *help);
}
cmCacheManager::OutputKey(fout, i.GetName());
- fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
+ fout << ':' << cmState::CacheEntryTypeToString(t) << '=';
cmCacheManager::OutputValue(fout, i.GetValue());
- fout << "\n";
+ fout << '\n';
cmCacheManager::OutputNewlineTruncationWarning(fout, i.GetName(),
i.GetValue(), messenger);
}
}
- fout << "\n";
+ fout << '\n';
fout.Close();
std::string checkCacheFile = cmStrCat(path, "/CMakeFiles");
cmSystemTools::MakeDirectory(checkCacheFile);
@@ -430,7 +428,7 @@ void cmCacheManager::OutputHelpString(std::ostream& fout,
fout << "\\n";
}
oneLine = helpString.substr(pos, i - pos);
- fout << oneLine << "\n";
+ fout << oneLine << '\n';
pos = i;
}
}
@@ -452,7 +450,7 @@ void cmCacheManager::OutputWarningComment(std::ostream& fout,
fout << "\\n";
}
oneLine = message.substr(pos, i - pos);
- fout << oneLine << "\n";
+ fout << oneLine << '\n';
pos = i;
}
}
@@ -519,17 +517,17 @@ cmProp cmCacheManager::GetInitializedCacheValue(const std::string& key) const
void cmCacheManager::PrintCache(std::ostream& out) const
{
- out << "=================================================" << std::endl;
- out << "CMakeCache Contents:" << std::endl;
+ out << "=================================================\n"
+ "CMakeCache Contents:\n";
for (auto const& i : this->Cache) {
if (i.second.Type != cmStateEnums::INTERNAL) {
- out << i.first << " = " << i.second.Value << std::endl;
+ out << i.first << " = " << i.second.Value << '\n';
}
}
- out << "\n\n";
- out << "To change values in the CMakeCache, " << std::endl
- << "edit CMakeCache.txt in your output directory.\n";
- out << "=================================================" << std::endl;
+ out << "\n\n"
+ "To change values in the CMakeCache, \n"
+ "edit CMakeCache.txt in your output directory.\n"
+ "=================================================\n";
}
void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx
index 9e152ff804..94b6e186a1 100644
--- a/Source/cmCallVisualStudioMacro.cxx
+++ b/Source/cmCallVisualStudioMacro.cxx
@@ -43,8 +43,7 @@ static bool LogErrorsAsMessages;
if (LogErrorsAsMessages) { \
std::ostringstream _hresult_oss; \
_hresult_oss.flags(std::ios::hex); \
- _hresult_oss << context << " failed HRESULT, hr = 0x" << hr \
- << std::endl; \
+ _hresult_oss << context << " failed HRESULT, hr = 0x" << hr << '\n'; \
_hresult_oss.flags(std::ios::dec); \
_hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
cmSystemTools::Message(_hresult_oss.str()); \
@@ -98,32 +97,37 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
DISPATCH_METHOD, &params, &result, &excep, &arg);
std::ostringstream oss;
- oss << std::endl;
- oss << "Invoke(ExecuteCommand)" << std::endl;
- oss << " Macro: " << macro << std::endl;
- oss << " Args: " << args << std::endl;
+ /* clang-format off */
+ oss << "\nInvoke(ExecuteCommand)\n"
+ " Macro: " << macro << "\n"
+ " Args: " << args << '\n';
+ /* clang-format on */
if (DISP_E_EXCEPTION == hr) {
- oss << "DISP_E_EXCEPTION EXCEPINFO:" << excep.wCode << std::endl;
- oss << " wCode: " << excep.wCode << std::endl;
- oss << " wReserved: " << excep.wReserved << std::endl;
+ /* clang-format off */
+ oss << "DISP_E_EXCEPTION EXCEPINFO:" << excep.wCode << "\n"
+ " wCode: " << excep.wCode << "\n"
+ " wReserved: " << excep.wReserved << '\n';
+ /* clang-format on */
if (excep.bstrSource) {
oss << " bstrSource: " << (const char*)(_bstr_t)excep.bstrSource
- << std::endl;
+ << '\n';
}
if (excep.bstrDescription) {
oss << " bstrDescription: "
- << (const char*)(_bstr_t)excep.bstrDescription << std::endl;
+ << (const char*)(_bstr_t)excep.bstrDescription << '\n';
}
if (excep.bstrHelpFile) {
oss << " bstrHelpFile: " << (const char*)(_bstr_t)excep.bstrHelpFile
- << std::endl;
+ << '\n';
}
- oss << " dwHelpContext: " << excep.dwHelpContext << std::endl;
- oss << " pvReserved: " << excep.pvReserved << std::endl;
- oss << " pfnDeferredFillIn: "
- << reinterpret_cast<void*>(excep.pfnDeferredFillIn) << std::endl;
- oss << " scode: " << excep.scode << std::endl;
+ /* clang-format off */
+ oss << " dwHelpContext: " << excep.dwHelpContext << "\n"
+ " pvReserved: " << excep.pvReserved << "\n"
+ " pfnDeferredFillIn: "
+ << reinterpret_cast<void*>(excep.pfnDeferredFillIn) << "\n"
+ " scode: " << excep.scode << '\n';
+ /* clang-format on */
}
std::string exstr(oss.str());
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 003019ae57..ea31417d77 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -276,8 +276,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
<< "\"\nhowever it is also "
"a subdirectory of the "
<< (inBinary ? "build" : "source") << " tree:\n \""
- << (inBinary ? topBinaryDir : topSourceDir) << "\""
- << std::endl;
+ << (inBinary ? topBinaryDir : topSourceDir) << "\"\n";
target->GetLocalGenerator()->IssueMessage(
MessageType::AUTHOR_WARNING, s.str());
CM_FALLTHROUGH;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 94483cad44..062f8e967d 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1011,7 +1011,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
cm::make_unique<cmGeneratedFileStream>(buildFilePath);
*this->CompileCommandsStream << "[\n";
} else {
- *this->CompileCommandsStream << "," << std::endl;
+ *this->CompileCommandsStream << ",\n";
}
std::string sourceFileName = sourceFile;
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 679d24451d..582877f845 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -159,7 +159,7 @@ void cmGlobalUnixMakefileGenerator3::Generate()
this->WriteMainCMakefile();
if (this->CommandDatabase) {
- *this->CommandDatabase << std::endl << "]";
+ *this->CommandDatabase << "\n]";
this->CommandDatabase.reset();
}
}
@@ -174,21 +174,20 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
"/compile_commands.json";
this->CommandDatabase =
cm::make_unique<cmGeneratedFileStream>(commandDatabaseName);
- *this->CommandDatabase << "[" << std::endl;
+ *this->CommandDatabase << "[\n";
} else {
- *this->CommandDatabase << "," << std::endl;
+ *this->CommandDatabase << ",\n";
}
- *this->CommandDatabase << "{" << std::endl
+ *this->CommandDatabase << "{\n"
<< R"( "directory": ")"
<< cmGlobalGenerator::EscapeJSON(workingDirectory)
- << "\"," << std::endl
+ << "\",\n"
<< R"( "command": ")"
<< cmGlobalGenerator::EscapeJSON(compileCommand)
- << "\"," << std::endl
+ << "\",\n"
<< R"( "file": ")"
- << cmGlobalGenerator::EscapeJSON(sourceFile) << "\""
- << std::endl
- << "}";
+ << cmGlobalGenerator::EscapeJSON(sourceFile)
+ << "\"\n}";
}
void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 7e54f11c1f..e62371d396 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -207,9 +207,8 @@ void cmLocalNinjaGenerator::WriteBuildFileTop()
void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
- os << "# Project: " << this->GetProjectName() << std::endl
- << "# Configurations: " << cmJoin(this->GetConfigNames(), ", ")
- << std::endl;
+ os << "# Project: " << this->GetProjectName() << '\n'
+ << "# Configurations: " << cmJoin(this->GetConfigNames(), ", ") << '\n';
cmGlobalNinjaGenerator::WriteDivider(os);
}
@@ -236,8 +235,7 @@ void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os)
cmGlobalNinjaGenerator::WriteComment(
os, "Minimal version of Ninja required by this file");
- os << "ninja_required_version = " << requiredVersion << std::endl
- << std::endl;
+ os << "ninja_required_version = " << requiredVersion << "\n\n";
}
void cmLocalNinjaGenerator::WriteNinjaConfigurationVariable(
@@ -266,9 +264,8 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os)
unsigned int jobs;
if (eq != std::string::npos &&
sscanf(pool.c_str() + eq, "=%u", &jobs) == 1) {
- os << "pool " << pool.substr(0, eq) << std::endl;
- os << " depth = " << jobs << std::endl;
- os << std::endl;
+ os << "pool " << pool.substr(0, eq) << "\n depth = " << jobs
+ << "\n\n";
} else {
cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': " +
pool);
@@ -280,8 +277,7 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os)
void cmLocalNinjaGenerator::WriteNinjaFilesInclusionConfig(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
- os << "# Include auxiliary files.\n"
- << "\n";
+ os << "# Include auxiliary files.\n\n";
cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
std::string const ninjaCommonFile =
ng->NinjaOutputPath(cmGlobalNinjaMultiGenerator::NINJA_COMMON_FILE);
@@ -294,8 +290,7 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusionConfig(std::ostream& os)
void cmLocalNinjaGenerator::WriteNinjaFilesInclusionCommon(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
- os << "# Include auxiliary files.\n"
- << "\n";
+ os << "# Include auxiliary files.\n\n";
cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
std::string const ninjaRulesFile =
ng->NinjaOutputPath(cmGlobalNinjaGenerator::NINJA_RULES_FILE);
@@ -308,14 +303,14 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusionCommon(std::ostream& os)
void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
- os << "# Write statements declared in CMakeLists.txt:" << std::endl
+ os << "# Write statements declared in CMakeLists.txt:\n"
<< "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE")
- << std::endl;
+ << '\n';
if (this->IsRootMakefile()) {
- os << "# Which is the root file." << std::endl;
+ os << "# Which is the root file.\n";
}
cmGlobalNinjaGenerator::WriteDivider(os);
- os << std::endl;
+ os << '\n';
}
void cmLocalNinjaGenerator::AppendTargetOutputs(cmGeneratorTarget* target,
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 6caf81674f..593a6d9e77 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1326,10 +1326,9 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
int result;
if (!ftc->Compare(internalDependFile, tgtInfo, &result) || result < 0) {
if (verbose) {
- std::ostringstream msg;
- msg << "Dependee \"" << tgtInfo << "\" is newer than depender \""
- << internalDependFile << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str());
+ cmSystemTools::Stdout(cmStrCat("Dependee \"", tgtInfo,
+ "\" is newer than depender \"",
+ internalDependFile, "\".\n"));
}
needRescanDependInfo = true;
}
@@ -1346,10 +1345,9 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
if (!ftc->Compare(internalDependFile, dirInfoFile, &result) ||
result < 0) {
if (verbose) {
- std::ostringstream msg;
- msg << "Dependee \"" << dirInfoFile << "\" is newer than depender \""
- << internalDependFile << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str());
+ cmSystemTools::Stdout(cmStrCat("Dependee \"", dirInfoFile,
+ "\" is newer than depender \"",
+ internalDependFile, "\".\n"));
}
needRescanDirInfo = true;
}
@@ -1515,11 +1513,9 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
if (cmSystemTools::FileExists(dependee) &&
!cmSystemTools::FileExists(depender)) {
if (verbose) {
- std::ostringstream msg;
- msg << "Deleting primary custom command output \"" << dependee
- << "\" because another output \"" << depender
- << "\" does not exist." << std::endl;
- cmSystemTools::Stdout(msg.str());
+ cmSystemTools::Stdout(cmStrCat(
+ "Deleting primary custom command output \"", dependee,
+ "\" because another output \"", depender, "\" does not exist.\n"));
}
cmSystemTools::RemoveFile(dependee);
}
@@ -1966,7 +1962,7 @@ std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os)
{
os << "#======================================"
- << "=======================================\n";
+ "=======================================\n";
}
void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
@@ -1974,7 +1970,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
{
// Write the given string to the stream with escaping to get it back
// into CMake through the lexical scanner.
- os << "\"";
+ os << '"';
for (char c : s) {
if (c == '\\') {
os << "\\\\";
@@ -1984,7 +1980,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
os << c;
}
}
- os << "\"";
+ os << '"';
}
std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 91daeda865..4fb84eec23 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -299,8 +299,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
dependFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
depFileStream << "# Empty dependencies file for "
<< this->GeneratorTarget->GetName() << ".\n"
- << "# This may be replaced when dependencies are built."
- << std::endl;
+ << "# This may be replaced when dependencies are built.\n";
}
// Open the flags file. This should be copy-if-different because the
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
index 34e21b2f22..666ba87698 100644
--- a/Source/cmWriteFileCommand.cxx
+++ b/Source/cmWriteFileCommand.cxx
@@ -72,7 +72,7 @@ bool cmWriteFileCommand(std::vector<std::string> const& args,
status.SetError(error);
return false;
}
- file << message << std::endl;
+ file << message << '\n';
file.close();
if (mode && !writable) {
cmSystemTools::SetPermissions(fileName.c_str(), mode);