Skip to content

Commit 8c15b96

Browse files
ShabbyXAngle LUCI CQ
authored andcommitted
Translator: Validate MaxFunctionParameters limit during parse
Bug: angleproject:349994211 Change-Id: Ic9e4a6d1279cdfdb8d24a029182f3c83a79ef05f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/7022016 Reviewed-by: Yuxin Hu <[email protected]> Reviewed-by: Geoff Lang <[email protected]> Commit-Queue: Shahbaz Youssefi <[email protected]>
1 parent 88002e3 commit 8c15b96

File tree

6 files changed

+11
-62
lines changed

6 files changed

+11
-62
lines changed

src/compiler.gni

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ angle_translator_sources = [
102102
"src/compiler/translator/ValidateGlobalInitializer.h",
103103
"src/compiler/translator/ValidateLimitations.cpp",
104104
"src/compiler/translator/ValidateLimitations.h",
105-
"src/compiler/translator/ValidateMaxParameters.cpp",
106-
"src/compiler/translator/ValidateMaxParameters.h",
107105
"src/compiler/translator/ValidateOutputs.cpp",
108106
"src/compiler/translator/ValidateOutputs.h",
109107
"src/compiler/translator/ValidateSwitch.cpp",

src/compiler/translator/Compiler.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "compiler/translator/ParseContext.h"
2828
#include "compiler/translator/SizeClipCullDistance.h"
2929
#include "compiler/translator/ValidateLimitations.h"
30-
#include "compiler/translator/ValidateMaxParameters.h"
3130
#include "compiler/translator/ValidateOutputs.h"
3231
#include "compiler/translator/ValidateTypeSizeLimitations.h"
3332
#include "compiler/translator/ValidateVaryingLocations.h"
@@ -1971,12 +1970,6 @@ bool TCompiler::limitExpressionComplexity(TIntermBlock *root)
19711970
return false;
19721971
}
19731972

1974-
if (!ValidateMaxParameters(root, mResources.MaxFunctionParameters))
1975-
{
1976-
mDiagnostics.globalError("Function has too many parameters.");
1977-
return false;
1978-
}
1979-
19801973
return true;
19811974
}
19821975

src/compiler/translator/ParseContext.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ TParseContext::TParseContext(TSymbolTable &symt,
390390
mMaxAtomicCounterBufferSize(resources.MaxAtomicCounterBufferSize),
391391
mMaxShaderStorageBufferBindings(resources.MaxShaderStorageBufferBindings),
392392
mMaxPixelLocalStoragePlanes(resources.MaxPixelLocalStoragePlanes),
393+
mMaxFunctionParameters(resources.MaxFunctionParameters),
393394
mDeclaringFunction(false),
394395
mDeclaringMain(false),
395396
mIsMainDeclared(false),
@@ -4734,8 +4735,15 @@ TIntermFunctionDefinition *TParseContext::addFunctionDefinition(
47344735
// Check that non-void functions have at least one return statement.
47354736
if (mCurrentFunctionType->getBasicType() != EbtVoid && !mFunctionReturnsValue)
47364737
{
4737-
error(location,
4738-
"function does not return a value:", functionPrototype->getFunction()->name());
4738+
error(location, "Function does not return a value",
4739+
functionPrototype->getFunction()->name());
4740+
}
4741+
if (mCompileOptions.limitExpressionComplexity &&
4742+
functionPrototype->getFunction()->getParamCount() >
4743+
static_cast<unsigned int>(mMaxFunctionParameters))
4744+
{
4745+
error(location, "Function has too many parameters",
4746+
functionPrototype->getFunction()->name());
47394747
}
47404748

47414749
if (functionBody == nullptr)

src/compiler/translator/ParseContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ class TParseContext : angle::NonCopyable
839839
int mMaxAtomicCounterBufferSize;
840840
int mMaxShaderStorageBufferBindings;
841841
int mMaxPixelLocalStoragePlanes;
842+
int mMaxFunctionParameters;
842843

843844
// keeps track of whether any of the built-ins that can be redeclared (see
844845
// IsRedeclarableBuiltIn()) has been marked as invariant/precise before the possible

src/compiler/translator/ValidateMaxParameters.cpp

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/compiler/translator/ValidateMaxParameters.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)