diff options
author | Brad King <brad.king@kitware.com> | 2012-11-27 18:35:02 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-11-27 18:35:02 (GMT) |
commit | 5f30a56f290acd7abd805e32f7537957ae78377d (patch) | |
tree | 0804f6d7630fdf716014de76b7638cabc6b6c0eb /Source/cmGeneratorExpressionEvaluator.cxx | |
parent | d5adbbcf9cf7443392a38eb980886833de104826 (diff) | |
parent | b581be07672e08cce4c29fa279b250d8e9c7aaba (diff) | |
download | CMake-5f30a56f290acd7abd805e32f7537957ae78377d.zip CMake-5f30a56f290acd7abd805e32f7537957ae78377d.tar.gz CMake-5f30a56f290acd7abd805e32f7537957ae78377d.tar.bz2 |
Merge topic 'generator-expression-fixes'
b581be0 Genex: Don't segfault on $<FOO,>
07749e3 Genex: Ensure that $<0:...> has a parameter.
ee96dc7 Genex: Extract a method to parse parameters.
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluator.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index c609000..102927e 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -66,6 +66,8 @@ static const struct ZeroNode : public cmGeneratorExpressionNode virtual bool GeneratesContent() const { return false; } + virtual bool AcceptsSingleArbitraryContentParameter() const { return true; } + std::string Evaluate(const std::vector<std::string> &, cmGeneratorExpressionContext *, const GeneratorExpressionContent *, @@ -642,6 +644,20 @@ std::string GeneratorExpressionContent::Evaluate( if (!node->GeneratesContent()) { + if (node->AcceptsSingleArbitraryContentParameter()) + { + if (this->ParamChildren.empty()) + { + reportError(context, this->GetOriginalExpression(), + "$<" + identifier + "> expression requires a parameter."); + } + } + else + { + std::vector<std::string> parameters; + this->EvaluateParameters(node, identifier, context, dagChecker, + parameters); + } return std::string(); } @@ -677,6 +693,23 @@ std::string GeneratorExpressionContent::Evaluate( } std::vector<std::string> parameters; + this->EvaluateParameters(node, identifier, context, dagChecker, parameters); + if (context->HadError) + { + return std::string(); + } + + return node->Evaluate(parameters, context, this, dagChecker); +} + +//---------------------------------------------------------------------------- +std::string GeneratorExpressionContent::EvaluateParameters( + const cmGeneratorExpressionNode *node, + const std::string &identifier, + cmGeneratorExpressionContext *context, + cmGeneratorExpressionDAGChecker *dagChecker, + std::vector<std::string> ¶meters) const +{ { std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator pit = this->ParamChildren.begin(); @@ -732,10 +765,8 @@ std::string GeneratorExpressionContent::Evaluate( { reportError(context, this->GetOriginalExpression(), "$<" + identifier + "> expression requires at least one parameter."); - return std::string(); } - - return node->Evaluate(parameters, context, this, dagChecker); + return std::string(); } //---------------------------------------------------------------------------- |