diff options
author | Brad King <brad.king@kitware.com> | 2019-09-05 14:31:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-09-05 14:31:56 (GMT) |
commit | 5acf0de1feb83a8ec5d8f1348091501919b17cad (patch) | |
tree | 0d95a98e98ed5832159b97cbf8bc2fd521d7d3e1 | |
parent | 6db8f6a410d99e9a66847530bb520b329d2f1a9e (diff) | |
download | CMake-5acf0de1feb83a8ec5d8f1348091501919b17cad.zip CMake-5acf0de1feb83a8ec5d8f1348091501919b17cad.tar.gz CMake-5acf0de1feb83a8ec5d8f1348091501919b17cad.tar.bz2 |
cmLocalGenerator: Remove AppendFlags 'const char*' overload
Update call sites to ensure the `std::string` argument can be
constructed safely.
-rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalCommonGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 18 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.h | 1 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 4 |
8 files changed, 15 insertions, 32 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 49db505..54443f2 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -90,7 +90,7 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags( } if (var) { this->LocalCommonGenerator->AppendFlags( - flags, this->Makefile->GetDefinition(var)); + flags, this->Makefile->GetSafeDefinition(var)); } } diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 7c36bdc..f86955d 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -35,10 +35,8 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags( std::string flags; // Enable module output if necessary. - if (const char* modout_flag = - this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) { - this->AppendFlags(flags, modout_flag); - } + this->AppendFlags( + flags, this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODOUT_FLAG")); // Add a module output directory flag if necessary. std::string mod_dir = diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e2402ad..9152e94 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1125,10 +1125,10 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name)); } } - this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS")); + this->AppendFlags(flags, target->GetSafeProperty("STATIC_LIBRARY_FLAGS")); if (!config.empty()) { std::string name = "STATIC_LIBRARY_FLAGS_" + config; - this->AppendFlags(flags, target->GetProperty(name)); + this->AppendFlags(flags, target->GetSafeProperty(name)); } std::vector<std::string> options; @@ -1744,7 +1744,7 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, // Add flags for dealing with shared libraries for this language. if (shared) { this->AppendFlags(flags, - this->Makefile->GetDefinition( + this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS"))); } } @@ -2090,12 +2090,12 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, { // Add the flags from the variable itself. std::string flagsVar = var; - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); + this->AppendFlags(flags, this->Makefile->GetSafeDefinition(flagsVar)); // Add the flags from the build-type specific variable. if (!config.empty()) { flagsVar += "_"; flagsVar += cmSystemTools::UpperCase(config); - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); + this->AppendFlags(flags, this->Makefile->GetSafeDefinition(flagsVar)); } } @@ -2110,14 +2110,6 @@ void cmLocalGenerator::AppendFlags(std::string& flags, } } -void cmLocalGenerator::AppendFlags(std::string& flags, - const char* newFlags) const -{ - if (newFlags && *newFlags) { - this->AppendFlags(flags, std::string(newFlags)); - } -} - void cmLocalGenerator::AppendFlagEscape(std::string& flags, const std::string& rawFlag) const { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 515ffae..7cf8cd0 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -121,7 +121,6 @@ public: //! Append flags to a string. virtual void AppendFlags(std::string& flags, const std::string& newFlags) const; - virtual void AppendFlags(std::string& flags, const char* newFlags) const; virtual void AppendFlagEscape(std::string& flags, const std::string& rawFlag) const; void AddPchDependencies(cmGeneratorTarget* target, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 106e506..320a58b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -831,12 +831,6 @@ void cmLocalUnixMakefileGenerator3::AppendFlags( this->cmLocalGenerator::AppendFlags(flags, newFlags); } -void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags, - const char* newFlags) const -{ - this->cmLocalGenerator::AppendFlags(flags, newFlags); -} - void cmLocalUnixMakefileGenerator3::AppendRuleDepend( std::vector<std::string>& depends, const char* ruleFileName) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index c8e4b0e..745e251 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -90,7 +90,6 @@ public: // append flags to a string void AppendFlags(std::string& flags, const std::string& newFlags) const override; - void AppendFlags(std::string& flags, const char* newFlags) const override; // append an echo command enum EchoColor diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 002addf..e44ca7b 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -135,7 +135,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( std::string export_flag_var = cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG"); this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetDefinition(export_flag_var)); + linkFlags, this->Makefile->GetSafeDefinition(export_flag_var)); } this->LocalGenerator->AppendFlags(linkFlags, @@ -387,10 +387,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) { this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); + linkFlags, this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE")); } else { this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); + linkFlags, + this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE")); } // Add symbol export flags if necessary. @@ -398,7 +399,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string export_flag_var = cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG"); this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetDefinition(export_flag_var)); + linkFlags, this->Makefile->GetSafeDefinition(export_flag_var)); } this->LocalGenerator->AppendFlags(linkFlags, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 4a60aa9..1f6986b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -89,12 +89,12 @@ void cmMakefileTargetGenerator::GetTargetLinkFlags( std::string& flags, const std::string& linkLanguage) { this->LocalGenerator->AppendFlags( - flags, this->GeneratorTarget->GetProperty("LINK_FLAGS")); + flags, this->GeneratorTarget->GetSafeProperty("LINK_FLAGS")); std::string linkFlagsConfig = cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(this->ConfigName)); this->LocalGenerator->AppendFlags( - flags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); + flags, this->GeneratorTarget->GetSafeProperty(linkFlagsConfig)); std::vector<std::string> opts; this->GeneratorTarget->GetLinkOptions(opts, this->ConfigName, linkLanguage); |