From fa169fe8a7f2066eaa40393b4b7979daf42065e4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 28 Jan 2016 22:10:26 +0100 Subject: [PATCH 1/5] Parser: Merge identical conditions --- Source/cmListFileCache.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 33731e0473..036a2b116f 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -181,9 +181,6 @@ bool cmListFile::ParseFile(const char* filename, bool topLevel, cmMakefile* mf) mf->SetPolicyVersion("2.4"); } } - } - - if (topLevel) { bool hasProject = false; // search for a project command for (std::vector::iterator i = this->Functions.begin(); From 87ffd76d1a33885a4cddff70a9909ad88c2aeacc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 28 Jan 2016 22:10:25 +0100 Subject: [PATCH 2/5] cmake: Make internal method file static --- Source/cmake.cxx | 4 ++-- Source/cmake.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 89ea9559d5..4d2dfe8552 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2225,7 +2225,7 @@ bool cmake::IsMessageTypeVisible(cmake::MessageType t) return isVisible; } -bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg) +static bool printMessagePreamble(cmake::MessageType t, std::ostream& msg) { // Construct the message header. if (t == cmake::FATAL_ERROR) { @@ -2312,7 +2312,7 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, } std::ostringstream msg; - if (!this->PrintMessagePreamble(t, msg)) { + if (!printMessagePreamble(t, msg)) { return; } diff --git a/Source/cmake.h b/Source/cmake.h index 266c33d3dd..f6d335fe86 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -500,8 +500,6 @@ private: * warning and error output CMake variables, in the cache. */ bool IsMessageTypeVisible(cmake::MessageType t); - - bool PrintMessagePreamble(cmake::MessageType t, std::ostream& msg); }; #define CMAKE_STANDARD_OPTIONS_TABLE \ From 6e65808516994fe268c4ec87107fca6da6600a9c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 28 Jan 2016 22:10:23 +0100 Subject: [PATCH 3/5] cmake: Fix constness of methods --- Source/cmake.cxx | 15 ++++++++------- Source/cmake.h | 14 +++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 4d2dfe8552..605da81451 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2176,7 +2176,7 @@ static bool cmakeCheckStampList(const char* stampList) return true; } -cmake::MessageType cmake::ConvertMessageType(cmake::MessageType t) +cmake::MessageType cmake::ConvertMessageType(cmake::MessageType t) const { bool warningsAsErrors; @@ -2200,7 +2200,7 @@ cmake::MessageType cmake::ConvertMessageType(cmake::MessageType t) return t; } -bool cmake::IsMessageTypeVisible(cmake::MessageType t) +bool cmake::IsMessageTypeVisible(cmake::MessageType t) const { bool isVisible = true; @@ -2296,7 +2296,8 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg) } void cmake::IssueMessage(cmake::MessageType t, std::string const& text, - cmListFileBacktrace const& backtrace, bool force) + cmListFileBacktrace const& backtrace, + bool force) const { if (!force) { // override the message type, if needed, for warnings and errors @@ -2448,7 +2449,7 @@ void cmake::RunCheckForUnusedVariables() #endif } -bool cmake::GetSuppressDevWarnings(cmMakefile const* mf) +bool cmake::GetSuppressDevWarnings(cmMakefile const* mf) const { /* * The suppression CMake variable may be set in the CMake configuration file @@ -2482,7 +2483,7 @@ void cmake::SetSuppressDevWarnings(bool b) cmState::INTERNAL); } -bool cmake::GetSuppressDeprecatedWarnings(cmMakefile const* mf) +bool cmake::GetSuppressDeprecatedWarnings(cmMakefile const* mf) const { /* * The suppression CMake variable may be set in the CMake configuration file @@ -2517,7 +2518,7 @@ void cmake::SetSuppressDeprecatedWarnings(bool b) cmState::INTERNAL); } -bool cmake::GetDevWarningsAsErrors(cmMakefile const* mf) +bool cmake::GetDevWarningsAsErrors(cmMakefile const* mf) const { if (mf) { return (mf->IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") && @@ -2548,7 +2549,7 @@ void cmake::SetDevWarningsAsErrors(bool b) cmState::INTERNAL); } -bool cmake::GetDeprecatedWarningsAsErrors(cmMakefile const* mf) +bool cmake::GetDeprecatedWarningsAsErrors(cmMakefile const* mf) const { if (mf) { return mf->IsOn("CMAKE_ERROR_DEPRECATED"); diff --git a/Source/cmake.h b/Source/cmake.h index f6d335fe86..29c010de4d 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -339,7 +339,7 @@ public: * Returns false, by default, if developer warnings should be shown, true * otherwise. */ - bool GetSuppressDevWarnings(cmMakefile const* mf = NULL); + bool GetSuppressDevWarnings(cmMakefile const* mf = NULL) const; /* * Set the state of the suppression of developer (author) warnings. */ @@ -350,7 +350,7 @@ public: * Returns false, by default, if deprecated warnings should be shown, true * otherwise. */ - bool GetSuppressDeprecatedWarnings(cmMakefile const* mf = NULL); + bool GetSuppressDeprecatedWarnings(cmMakefile const* mf = NULL) const; /* * Set the state of the suppression of deprecated warnings. */ @@ -361,7 +361,7 @@ public: * Returns false, by default, if warnings should not be treated as errors, * true otherwise. */ - bool GetDevWarningsAsErrors(cmMakefile const* mf = NULL); + bool GetDevWarningsAsErrors(cmMakefile const* mf = NULL) const; /** * Set the state of treating developer (author) warnings as errors. */ @@ -372,7 +372,7 @@ public: * Returns false, by default, if warnings should not be treated as errors, * true otherwise. */ - bool GetDeprecatedWarningsAsErrors(cmMakefile const* mf = NULL); + bool GetDeprecatedWarningsAsErrors(cmMakefile const* mf = NULL) const; /** * Set the state of treating developer (author) warnings as errors. */ @@ -382,7 +382,7 @@ public: void IssueMessage( cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace = cmListFileBacktrace(), - bool force = false); + bool force = false) const; ///! run the --build option int Build(const std::string& dir, const std::string& target, @@ -493,13 +493,13 @@ private: * Convert a message type between a warning and an error, based on the state * of the error output CMake variables, in the cache. */ - cmake::MessageType ConvertMessageType(cmake::MessageType t); + cmake::MessageType ConvertMessageType(cmake::MessageType t) const; /* * Check if messages of this type should be output, based on the state of the * warning and error output CMake variables, in the cache. */ - bool IsMessageTypeVisible(cmake::MessageType t); + bool IsMessageTypeVisible(cmake::MessageType t) const; }; #define CMAKE_STANDARD_OPTIONS_TABLE \ From f9cc43ea37d8b4e2a482cb9004cec2bd8f824857 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Wed, 8 Jun 2016 15:18:28 +0200 Subject: [PATCH 4/5] cmake: remove unnused member Verbose --- Source/cmake.cxx | 9 ++------- Source/cmake.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 605da81451..b76342611c 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -145,7 +145,6 @@ cmake::cmake() } #endif - this->Verbose = false; this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; @@ -555,9 +554,7 @@ void cmake::SetArgs(const std::vector& args, this->VSSolutionFile = args[++i]; } #endif - else if (arg.find("-V", 0) == 0) { - this->Verbose = true; - } else if (arg.find("-D", 0) == 0) { + else if (arg.find("-D", 0) == 0) { // skip for now } else if (arg.find("-U", 0) == 0) { // skip for now @@ -1989,9 +1986,7 @@ int cmake::GetSystemInformation(std::vector& args) bool writeToStdout = true; for (unsigned int i = 1; i < args.size(); ++i) { std::string arg = args[i]; - if (arg.find("-V", 0) == 0) { - this->Verbose = true; - } else if (arg.find("-G", 0) == 0) { + if (arg.find("-G", 0) == 0) { std::string value = arg.substr(2); if (value.empty()) { ++i; diff --git a/Source/cmake.h b/Source/cmake.h index 29c010de4d..4958a05dc6 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -455,7 +455,6 @@ private: void operator=(const cmake&); // Not implemented. ProgressCallbackType ProgressCallback; void* ProgressCallbackClientData; - bool Verbose; bool InTryCompile; WorkingMode CurrentWorkingMode; bool DebugOutput; From 9f25fc4dbb0fa3c027beb46c03c8b18507811cab Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Wed, 8 Jun 2016 22:29:15 +0200 Subject: [PATCH 5/5] Prefer std::ostream& over derivatives as parameters --- Source/CPack/cmCPackNSISGenerator.cxx | 8 ++++---- Source/CPack/cmCPackNSISGenerator.h | 6 +++--- Source/CTest/cmCTestBatchTestHandler.cxx | 4 ++-- Source/CTest/cmCTestBatchTestHandler.h | 4 ++-- Source/cmTarget.cxx | 3 +-- Source/cmTarget.h | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 9fa588d076..5123edda24 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -516,8 +516,8 @@ int cmCPackNSISGenerator::InitializeInternal() return this->Superclass::InitializeInternal(); } -void cmCPackNSISGenerator::CreateMenuLinks(std::ostringstream& str, - std::ostringstream& deleteStr) +void cmCPackNSISGenerator::CreateMenuLinks(std::ostream& str, + std::ostream& deleteStr) { const char* cpackMenuLinks = this->GetOption("CPACK_NSIS_MENU_LINKS"); if (!cpackMenuLinks) { @@ -621,7 +621,7 @@ bool cmCPackNSISGenerator::SupportsComponentInstallation() const } std::string cmCPackNSISGenerator::CreateComponentDescription( - cmCPackComponent* component, std::ostringstream& macrosOut) + cmCPackComponent* component, std::ostream& macrosOut) { // Basic description of the component std::string componentCode = "Section "; @@ -873,7 +873,7 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription( } std::string cmCPackNSISGenerator::CreateComponentGroupDescription( - cmCPackComponentGroup* group, std::ostringstream& macrosOut) + cmCPackComponentGroup* group, std::ostream& macrosOut) { if (group->Components.empty() && group->Subgroups.empty()) { // Silently skip empty groups. NSIS doesn't support them. diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index fa52902d61..ae3ccca6e3 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -40,7 +40,7 @@ public: protected: virtual int InitializeInternal(); - void CreateMenuLinks(std::ostringstream& str, std::ostringstream& deleteStr); + void CreateMenuLinks(std::ostream& str, std::ostream& deleteStr); int PackageFiles(); virtual const char* GetOutputExtension() { return ".exe"; } virtual const char* GetOutputPostfix() { return "win32"; } @@ -56,7 +56,7 @@ protected: /// particular component. Any added macros will be emitted via /// macrosOut. std::string CreateComponentDescription(cmCPackComponent* component, - std::ostringstream& macrosOut); + std::ostream& macrosOut); /// Produce NSIS code that selects all of the components that this component /// depends on, recursively. @@ -72,7 +72,7 @@ protected: /// particular component group, including its components. Any /// added macros will be emitted via macrosOut. std::string CreateComponentGroupDescription(cmCPackComponentGroup* group, - std::ostringstream& macrosOut); + std::ostream& macrosOut); /// Translations any newlines found in the string into \\r\\n, so that the /// resulting string can be used within NSIS. diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx index 386c8d5230..70f84cb1ab 100644 --- a/Source/CTest/cmCTestBatchTestHandler.cxx +++ b/Source/CTest/cmCTestBatchTestHandler.cxx @@ -45,7 +45,7 @@ void cmCTestBatchTestHandler::WriteBatchScript() fout.close(); } -void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout) +void cmCTestBatchTestHandler::WriteSrunArgs(int test, std::ostream& fout) { cmCTestTestHandler::cmCTestTestProperties* properties = this->Properties[test]; @@ -73,7 +73,7 @@ void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout) } } -void cmCTestBatchTestHandler::WriteTestCommand(int test, cmsys::ofstream& fout) +void cmCTestBatchTestHandler::WriteTestCommand(int test, std::ostream& fout) { std::vector args = this->Properties[test]->Args; std::vector processArgs; diff --git a/Source/CTest/cmCTestBatchTestHandler.h b/Source/CTest/cmCTestBatchTestHandler.h index 7a2a4a2638..ed60ea3c9c 100644 --- a/Source/CTest/cmCTestBatchTestHandler.h +++ b/Source/CTest/cmCTestBatchTestHandler.h @@ -33,8 +33,8 @@ public: protected: void WriteBatchScript(); - void WriteSrunArgs(int test, cmsys::ofstream& fout); - void WriteTestCommand(int test, cmsys::ofstream& fout); + void WriteSrunArgs(int test, std::ostream& fout); + void WriteTestCommand(int test, std::ostream& fout); void SubmitBatchScript(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f435a1d7a6..da2a64993d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -580,8 +580,7 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature, return ret; } -void cmTarget::GetTllSignatureTraces(std::ostringstream& s, - TLLSignature sig) const +void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const { const char* sigString = (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 71ba0cd7c6..f91e5c68dd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -156,7 +156,7 @@ public: }; bool PushTLLCommandTrace(TLLSignature signature, cmListFileContext const& lfc); - void GetTllSignatureTraces(std::ostringstream& s, TLLSignature sig) const; + void GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const; void MergeLinkLibraries(cmMakefile& mf, const std::string& selfname, const LinkLibraryVectorType& libs);