Commit a7b60f13 by Shahbaz Youssefi Committed by Commit Bot

Translator: Validate multi-declarations are separated

Many transformations only look at the first variable in a TIntermDeclaration. This change validates that once the SeparateDeclarations transformation has been run, multi-declarations are not reintroduced. Bug: angleproject:2733 Change-Id: If5f96689cbdd28817c479dd7c495b91535f87199 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2815565Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 2feb3db5
...@@ -561,6 +561,8 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root, ...@@ -561,6 +561,8 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
const TParseContext &parseContext, const TParseContext &parseContext,
ShCompileOptions compileOptions) ShCompileOptions compileOptions)
{ {
mValidateASTOptions = {};
// Disallow expressions deemed too complex. // Disallow expressions deemed too complex.
if ((compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY) != 0 && !limitExpressionComplexity(root)) if ((compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY) != 0 && !limitExpressionComplexity(root))
{ {
......
...@@ -61,6 +61,9 @@ class ValidateAST : public TIntermTraverser ...@@ -61,6 +61,9 @@ class ValidateAST : public TIntermTraverser
// For validateNullNodes // For validateNullNodes
bool mNullNodesFailed = false; bool mNullNodesFailed = false;
// For validateMultiDeclarations
bool mMultiDeclarationsFailed = false;
}; };
bool ValidateAST::validate(TIntermNode *root, bool ValidateAST::validate(TIntermNode *root,
...@@ -218,6 +221,12 @@ bool ValidateAST::visitDeclaration(Visit visit, TIntermDeclaration *node) ...@@ -218,6 +221,12 @@ bool ValidateAST::visitDeclaration(Visit visit, TIntermDeclaration *node)
{ {
visitNode(visit, node); visitNode(visit, node);
expectNonNullChildren(visit, node, 0); expectNonNullChildren(visit, node, 0);
if (mOptions.validateMultiDeclarations && node->getSequence()->size() > 1)
{
mMultiDeclarationsFailed = true;
}
return true; return true;
} }
...@@ -240,7 +249,7 @@ void ValidateAST::visitPreprocessorDirective(TIntermPreprocessorDirective *node) ...@@ -240,7 +249,7 @@ void ValidateAST::visitPreprocessorDirective(TIntermPreprocessorDirective *node)
bool ValidateAST::validateInternal() bool ValidateAST::validateInternal()
{ {
return !mSingleParentFailed && !mNullNodesFailed; return !mSingleParentFailed && !mNullNodesFailed && !mMultiDeclarationsFailed;
} }
} // anonymous namespace } // anonymous namespace
......
...@@ -46,7 +46,7 @@ struct ValidateASTOptions ...@@ -46,7 +46,7 @@ struct ValidateASTOptions
// Check that expression nodes have the correct type considering their operand(s). // Check that expression nodes have the correct type considering their operand(s).
bool validateExpressionTypes = true; // TODO bool validateExpressionTypes = true; // TODO
// If SeparateDeclarations has been run, check for the absence of multi declarations as well. // If SeparateDeclarations has been run, check for the absence of multi declarations as well.
bool validateMultiDeclarations = false; // TODO bool validateMultiDeclarations = false;
}; };
// Check for errors and output error messages on the context. // Check for errors and output error messages on the context.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment