summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2018-08-09 18:50:17 (GMT)
committerVitaly Stakhovsky <vvs31415@gitlab.org>2018-08-09 18:50:17 (GMT)
commitc530e2f74ff466b43651372d56bae543eec1a9f1 (patch)
tree6f3762cfef1f404bc8c9ee5b6efa1a865e970591
parentad4452d1bdabcdf039f812f2b709a905d76e8da0 (diff)
downloadCMake-c530e2f74ff466b43651372d56bae543eec1a9f1.zip
CMake-c530e2f74ff466b43651372d56bae543eec1a9f1.tar.gz
CMake-c530e2f74ff466b43651372d56bae543eec1a9f1.tar.bz2
cmCompiledGeneratorExpression::Evaluate(): return const std::string&
-rw-r--r--Source/cmGeneratorExpression.cxx11
-rw-r--r--Source/cmGeneratorExpression.h36
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx2
-rw-r--r--Source/cmGeneratorTarget.cxx2
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmServerProtocol.cxx7
-rw-r--r--Source/cmTestGenerator.cxx2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx19
8 files changed, 41 insertions, 40 deletions
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 64ec30d..f26c717 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -38,7 +38,7 @@ cmGeneratorExpression::~cmGeneratorExpression()
{
}
-const char* cmCompiledGeneratorExpression::Evaluate(
+const std::string& cmCompiledGeneratorExpression::Evaluate(
cmLocalGenerator* lg, const std::string& config, bool quiet,
const cmGeneratorTarget* headTarget,
cmGeneratorExpressionDAGChecker* dagChecker,
@@ -48,7 +48,7 @@ const char* cmCompiledGeneratorExpression::Evaluate(
language);
}
-const char* cmCompiledGeneratorExpression::Evaluate(
+const std::string& cmCompiledGeneratorExpression::Evaluate(
cmLocalGenerator* lg, const std::string& config, bool quiet,
const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget,
cmGeneratorExpressionDAGChecker* dagChecker,
@@ -61,12 +61,12 @@ const char* cmCompiledGeneratorExpression::Evaluate(
return this->EvaluateWithContext(context, dagChecker);
}
-const char* cmCompiledGeneratorExpression::EvaluateWithContext(
+const std::string& cmCompiledGeneratorExpression::EvaluateWithContext(
cmGeneratorExpressionContext& context,
cmGeneratorExpressionDAGChecker* dagChecker) const
{
if (!this->NeedsEvaluation) {
- return this->Input.c_str();
+ return this->Input;
}
this->Output.clear();
@@ -97,8 +97,7 @@ const char* cmCompiledGeneratorExpression::EvaluateWithContext(
this->DependTargets = context.DependTargets;
this->AllTargetsSeen = context.AllTargets;
- // TODO: Return a std::string from here instead?
- return this->Output.c_str();
+ return this->Output;
}
cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 9fd53c6..2899317 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -72,16 +72,17 @@ class cmCompiledGeneratorExpression
CM_DISABLE_COPY(cmCompiledGeneratorExpression)
public:
- const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
- bool quiet = false,
- cmGeneratorTarget const* headTarget = nullptr,
- cmGeneratorTarget const* currentTarget = nullptr,
- cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
- std::string const& language = std::string()) const;
- const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
- bool quiet, cmGeneratorTarget const* headTarget,
- cmGeneratorExpressionDAGChecker* dagChecker,
- std::string const& language = std::string()) const;
+ const std::string& Evaluate(
+ cmLocalGenerator* lg, const std::string& config, bool quiet = false,
+ cmGeneratorTarget const* headTarget = nullptr,
+ cmGeneratorTarget const* currentTarget = nullptr,
+ cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
+ std::string const& language = std::string()) const;
+ const std::string& Evaluate(
+ cmLocalGenerator* lg, const std::string& config, bool quiet,
+ cmGeneratorTarget const* headTarget,
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ std::string const& language = std::string()) const;
/** Get set of targets found during evaluations. */
std::set<cmGeneratorTarget*> const& GetTargets() const
@@ -126,7 +127,7 @@ public:
std::map<std::string, std::string>& mapping);
private:
- const char* EvaluateWithContext(
+ const std::string& EvaluateWithContext(
cmGeneratorExpressionContext& context,
cmGeneratorExpressionDAGChecker* dagChecker) const;
@@ -219,13 +220,16 @@ protected:
this->GeneratorExpression.Parse(expression);
if (dagChecker == nullptr) {
- return this->CompiledGeneratorExpression->Evaluate(
- this->LocalGenerator, this->Config, false, this->GeneratorTarget);
+ return this->CompiledGeneratorExpression
+ ->Evaluate(this->LocalGenerator, this->Config, false,
+ this->GeneratorTarget)
+ .c_str();
}
- return this->CompiledGeneratorExpression->Evaluate(
- this->LocalGenerator, this->Config, false, this->GeneratorTarget,
- dagChecker, this->Language);
+ return this->CompiledGeneratorExpression
+ ->Evaluate(this->LocalGenerator, this->Config, false,
+ this->GeneratorTarget, dagChecker, this->Language)
+ .c_str();
}
private:
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index a094fa5..e7a55e0 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -55,7 +55,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(
std::string outputFileName = this->OutputFileExpr->Evaluate(
lg, config, false, nullptr, nullptr, nullptr, lang);
- const std::string outputContent = inputExpression->Evaluate(
+ const std::string& outputContent = inputExpression->Evaluate(
lg, config, false, nullptr, nullptr, nullptr, lang);
if (cmSystemTools::FileIsFullPath(outputFileName)) {
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index c20fd13..1548374 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -5519,7 +5519,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
this->GetName(), "LINK_LIBRARIES", nullptr, nullptr);
cmGeneratorExpression ge(*btIt);
std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
- std::string const evaluated =
+ std::string const& evaluated =
cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
cmSystemTools::ExpandListArgument(evaluated, llibs);
if (cge->GetHadHeadSensitiveCondition()) {
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 21121f2..28cbdc7 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -679,7 +679,7 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(propertyValue);
if (cmSystemTools::IsOn(
- cge->Evaluate(target->GetLocalGenerator(), i))) {
+ cge->Evaluate(target->GetLocalGenerator(), i).c_str())) {
activeConfigs.insert(i);
}
}
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index c267160..f0a5e26 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -797,9 +797,8 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo,
// Remove any config specific variables from the output.
cmGeneratorExpression ge;
- auto cge = ge.Parse(command.c_str());
- const char* processed = cge->Evaluate(lg, config);
-
+ auto cge = ge.Parse(command);
+ const std::string& processed = cge->Evaluate(lg, config);
result[kCTEST_COMMAND] = processed;
// Build up the list of properties that may have been specified
@@ -810,7 +809,7 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo,
// Remove config variables from the value too.
auto cge_value = ge.Parse(prop.second.GetValue());
- const char* processed_value = cge_value->Evaluate(lg, config);
+ const std::string& processed_value = cge_value->Evaluate(lg, config);
entry[kVALUE_KEY] = processed_value;
properties.append(entry);
}
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index c532efb..796d2df 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -103,7 +103,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
}
} else {
// Use the command name given.
- exe = ge.Parse(exe.c_str())->Evaluate(this->LG, config);
+ exe = ge.Parse(exe)->Evaluate(this->LG, config);
cmSystemTools::ConvertToUnixSlashes(exe);
}
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 41567a3..553c78e 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1742,10 +1742,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)");
}
for (size_t i = 0; i != this->Configurations.size(); ++i) {
- if (0 ==
- strcmp(
- cge->Evaluate(this->LocalGenerator, this->Configurations[i]),
- "1")) {
+ if (cge->Evaluate(this->LocalGenerator, this->Configurations[i]) ==
+ "1") {
e2.WritePlatformConfigTag("DeploymentContent",
"'$(Configuration)|$(Platform)'=='" +
this->Configurations[i] + "|" +
@@ -1793,14 +1791,14 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
ge.Parse(shaderEnableDebug);
for (size_t i = 0; i != this->Configurations.size(); ++i) {
- const char* enableDebug =
+ const std::string& enableDebug =
cge->Evaluate(this->LocalGenerator, this->Configurations[i]);
- if (strlen(enableDebug) > 0) {
+ if (!enableDebug.empty()) {
e2.WritePlatformConfigTag(
"EnableDebuggingInformation",
"'$(Configuration)|$(Platform)'=='" + this->Configurations[i] +
"|" + this->Platform + "'",
- cmSystemTools::IsOn(enableDebug) ? "true" : "false");
+ cmSystemTools::IsOn(enableDebug.c_str()) ? "true" : "false");
}
}
}
@@ -1810,14 +1808,15 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
ge.Parse(shaderDisableOptimizations);
for (size_t i = 0; i != this->Configurations.size(); ++i) {
- const char* disableOptimizations =
+ const std::string& disableOptimizations =
cge->Evaluate(this->LocalGenerator, this->Configurations[i]);
- if (strlen(disableOptimizations) > 0) {
+ if (!disableOptimizations.empty()) {
e2.WritePlatformConfigTag(
"DisableOptimizations",
"'$(Configuration)|$(Platform)'=='" + this->Configurations[i] +
"|" + this->Platform + "'",
- (cmSystemTools::IsOn(disableOptimizations) ? "true" : "false"));
+ (cmSystemTools::IsOn(disableOptimizations.c_str()) ? "true"
+ : "false"));
}
}
}