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;
}
bool cmCTestVC::InitialCheckout(const char* command)
bool cmCTestVC::InitialCheckout(const std::string& command)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" First perform the initial checkout: " << command << "\n");

View File

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

View File

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

View File

@ -42,7 +42,8 @@ void cmInstalledFile::RemoveProperty(const std::string& prop)
}
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->AppendProperty(mf, prop, value);
@ -50,13 +51,14 @@ void cmInstalledFile::SetProperty(cmMakefile const* mf,
void cmInstalledFile::AppendProperty(cmMakefile const* mf,
const std::string& prop,
const char* value, bool /*asString*/)
const std::string& value,
bool /*asString*/)
{
cmListFileBacktrace backtrace = mf->GetBacktrace();
cmGeneratorExpression ge(backtrace);
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

View File

@ -49,10 +49,10 @@ public:
void RemoveProperty(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,
const char* value, bool asString = false);
const std::string& value, bool asString = false);
bool HasProperty(const std::string& prop) const;

View File

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