Source: use std::string overloads

This commit is contained in:
Vitaly Stakhovsky
2020-03-10 10:00:00 -04:00
parent c06e035601
commit a6cd48ac41
6 changed files with 23 additions and 26 deletions

View File

@@ -38,7 +38,7 @@ void cmCTestVC::SetSourceDirectory(std::string const& dir)
this->SourceDirectory = dir; this->SourceDirectory = dir;
} }
bool cmCTestVC::InitialCheckout(const char* command) bool cmCTestVC::InitialCheckout(const std::string& command)
{ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestLog(this->CTest, HANDLER_OUTPUT,
" First perform the initial checkout: " << command << "\n"); " First perform the initial checkout: " << command << "\n");

View File

@@ -36,7 +36,7 @@ public:
std::string GetNightlyTime(); std::string GetNightlyTime();
/** Prepare the work tree. */ /** Prepare the work tree. */
bool InitialCheckout(const char* command); bool InitialCheckout(const std::string& command);
/** Perform cleanup operations on the work tree. */ /** Perform cleanup operations on the work tree. */
void Cleanup(); void Cleanup();

View File

@@ -180,15 +180,12 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config,
auto i = this->FlagsByLanguage.find(language); auto i = this->FlagsByLanguage.find(language);
if (i == this->FlagsByLanguage.end()) { if (i == this->FlagsByLanguage.end()) {
std::string flags; std::string flags;
const char* lang = language.c_str(); this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget,
language, config);
this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, lang, this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
config); language, config);
this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
config);
this->LocalGenerator->AddVisibilityPresetFlags( this->LocalGenerator->AddVisibilityPresetFlags(
flags, this->GeneratorTarget, lang); flags, this->GeneratorTarget, language);
// Append old-style preprocessor definition flags. // Append old-style preprocessor definition flags.
if (this->Makefile->GetDefineFlags() != " ") { if (this->Makefile->GetDefineFlags() != " ") {
@@ -197,8 +194,8 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config,
} }
// Add target-specific flags. // Add target-specific flags.
this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang, this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
config); language, config);
std::map<std::string, std::string>::value_type entry(language, flags); std::map<std::string, std::string>::value_type entry(language, flags);
i = this->FlagsByLanguage.insert(entry).first; i = this->FlagsByLanguage.insert(entry).first;
@@ -211,13 +208,12 @@ std::string cmGhsMultiTargetGenerator::GetDefines(const std::string& language,
auto i = this->DefinesByLanguage.find(language); auto i = this->DefinesByLanguage.find(language);
if (i == this->DefinesByLanguage.end()) { if (i == this->DefinesByLanguage.end()) {
std::set<std::string> defines; std::set<std::string> defines;
const char* lang = language.c_str();
// Add preprocessor definitions for this target and configuration. // Add preprocessor definitions for this target and configuration.
this->LocalGenerator->GetTargetDefines(this->GeneratorTarget, config, this->LocalGenerator->GetTargetDefines(this->GeneratorTarget, config,
language, defines); language, defines);
std::string definesString; std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang); this->LocalGenerator->JoinDefines(defines, definesString, language);
std::map<std::string, std::string>::value_type entry(language, std::map<std::string, std::string>::value_type entry(language,
definesString); definesString);

View File

@@ -42,7 +42,8 @@ void cmInstalledFile::RemoveProperty(const std::string& prop)
} }
void cmInstalledFile::SetProperty(cmMakefile const* mf, void cmInstalledFile::SetProperty(cmMakefile const* mf,
const std::string& prop, const char* value) const std::string& prop,
const std::string& value)
{ {
this->RemoveProperty(prop); this->RemoveProperty(prop);
this->AppendProperty(mf, prop, value); this->AppendProperty(mf, prop, value);
@@ -50,13 +51,14 @@ void cmInstalledFile::SetProperty(cmMakefile const* mf,
void cmInstalledFile::AppendProperty(cmMakefile const* mf, void cmInstalledFile::AppendProperty(cmMakefile const* mf,
const std::string& prop, const std::string& prop,
const char* value, bool /*asString*/) const std::string& value,
bool /*asString*/)
{ {
cmListFileBacktrace backtrace = mf->GetBacktrace(); cmListFileBacktrace backtrace = mf->GetBacktrace();
cmGeneratorExpression ge(backtrace); cmGeneratorExpression ge(backtrace);
Property& property = this->Properties[prop]; Property& property = this->Properties[prop];
property.ValueExpressions.push_back(ge.Parse(value ? value : "")); property.ValueExpressions.push_back(ge.Parse(value));
} }
bool cmInstalledFile::HasProperty(const std::string& prop) const bool cmInstalledFile::HasProperty(const std::string& prop) const

View File

@@ -49,10 +49,10 @@ public:
void RemoveProperty(const std::string& prop); void RemoveProperty(const std::string& prop);
void SetProperty(cmMakefile const* mf, const std::string& prop, void SetProperty(cmMakefile const* mf, const std::string& prop,
const char* value); const std::string& value);
void AppendProperty(cmMakefile const* mf, const std::string& prop, void AppendProperty(cmMakefile const* mf, const std::string& prop,
const char* value, bool asString = false); const std::string& value, bool asString = false);
bool HasProperty(const std::string& prop) const; bool HasProperty(const std::string& prop) const;

View File

@@ -307,7 +307,7 @@ bool HandleTarget(cmTarget* target, cmMakefile& makefile,
if (remove) { if (remove) {
target->SetProperty(propertyName, nullptr); target->SetProperty(propertyName, nullptr);
} else { } else {
target->SetProperty(propertyName, propertyValue.c_str()); target->SetProperty(propertyName, propertyValue);
} }
} }
@@ -460,16 +460,15 @@ bool HandleCacheEntry(std::string const& cacheKey, const cmMakefile& makefile,
bool appendMode, bool remove) bool appendMode, bool remove)
{ {
// Set or append the property. // Set or append the property.
const char* value = propertyValue.c_str();
cmState* state = makefile.GetState(); cmState* state = makefile.GetState();
if (remove) { if (remove) {
state->RemoveCacheEntryProperty(cacheKey, propertyName); state->RemoveCacheEntryProperty(cacheKey, propertyName);
} }
if (appendMode) { if (appendMode) {
state->AppendCacheEntryProperty(cacheKey, propertyName, value, state->AppendCacheEntryProperty(cacheKey, propertyName, propertyValue,
appendAsString); appendAsString);
} else { } else {
state->SetCacheEntryProperty(cacheKey, propertyName, value); state->SetCacheEntryProperty(cacheKey, propertyName, propertyValue);
} }
return true; return true;
@@ -505,13 +504,13 @@ bool HandleInstall(cmInstalledFile* file, cmMakefile& makefile,
bool appendMode, bool remove) bool appendMode, bool remove)
{ {
// Set or append the property. // Set or append the property.
const char* value = propertyValue.c_str();
if (remove) { if (remove) {
file->RemoveProperty(propertyName); file->RemoveProperty(propertyName);
} else if (appendMode) { } else if (appendMode) {
file->AppendProperty(&makefile, propertyName, value, appendAsString); file->AppendProperty(&makefile, propertyName, propertyValue,
appendAsString);
} else { } else {
file->SetProperty(&makefile, propertyName, value); file->SetProperty(&makefile, propertyName, propertyValue);
} }
return true; return true;
} }