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.
This commit is contained in:
commit
5f30a56f29
|
@ -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();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -32,6 +32,7 @@ struct cmGeneratorExpressionContext
|
|||
};
|
||||
|
||||
struct cmGeneratorExpressionDAGChecker;
|
||||
struct cmGeneratorExpressionNode;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct cmGeneratorExpressionEvaluator
|
||||
|
@ -116,6 +117,13 @@ struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator
|
|||
|
||||
~GeneratorExpressionContent();
|
||||
|
||||
private:
|
||||
std::string EvaluateParameters(const cmGeneratorExpressionNode *node,
|
||||
const std::string &identifier,
|
||||
cmGeneratorExpressionContext *context,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||
std::vector<std::string> ¶meters) const;
|
||||
|
||||
private:
|
||||
std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren;
|
||||
std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren;
|
||||
|
|
|
@ -88,7 +88,15 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
|
|||
while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression
|
||||
&& this->it->TokenType != cmGeneratorExpressionToken::ColonSeparator)
|
||||
{
|
||||
this->ParseContent(identifier);
|
||||
if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
|
||||
{
|
||||
extendText(identifier, this->it);
|
||||
++this->it;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ParseContent(identifier);
|
||||
}
|
||||
if (this->it == this->Tokens.end())
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1,17 @@
|
|||
CMake Error at BadZero.cmake:2 \(add_custom_target\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<0>
|
||||
|
||||
\$<0> expression requires a parameter.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
+
|
||||
CMake Error at BadZero.cmake:2 \(add_custom_target\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<0,>
|
||||
|
||||
Expression did not evaluate to a known generator expression
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
add_custom_target(check ALL COMMAND check
|
||||
$<0>
|
||||
$<0,>
|
||||
VERBATIM)
|
|
@ -5,3 +5,4 @@ run_cmake(BadOR)
|
|||
run_cmake(BadAND)
|
||||
run_cmake(BadNOT)
|
||||
run_cmake(BadStrEqual)
|
||||
run_cmake(BadZero)
|
||||
|
|
Loading…
Reference in New Issue