Report warning whenever constant folding results are undefined
With recent constant folding changes, we are reporting warnings
whenever constant folding results are undefined for values passed in,
this change adds that warning at all the places where it was missing.
BUG=angleproject:913
TEST=dEQP Tests, angle_unittests
Change-Id: Ief8380488e2a4807c91ddac06d342cb172433b9d
Reviewed-on: https://chromium-review.googlesource.com/272879
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index 72e3b42..1bac12c 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -1289,7 +1289,7 @@
case EOpAsin:
// For asin(x), results are undefined if |x| > 1, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && fabsf(unionArray[i].getFConst()) > 1.0f)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
else if (!foldFloatTypeUnary(unionArray[i], &asinf, infoSink, &tempConstArray[i]))
return nullptr;
break;
@@ -1297,7 +1297,7 @@
case EOpAcos:
// For acos(x), results are undefined if |x| > 1, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && fabsf(unionArray[i].getFConst()) > 1.0f)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
else if (!foldFloatTypeUnary(unionArray[i], &acosf, infoSink, &tempConstArray[i]))
return nullptr;
break;
@@ -1330,7 +1330,7 @@
case EOpAcosh:
// For acosh(x), results are undefined if x < 1, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && unionArray[i].getFConst() < 1.0f)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
else if (!foldFloatTypeUnary(unionArray[i], &acoshf, infoSink, &tempConstArray[i]))
return nullptr;
break;
@@ -1338,7 +1338,7 @@
case EOpAtanh:
// For atanh(x), results are undefined if |x| >= 1, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && fabsf(unionArray[i].getFConst()) >= 1.0f)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
else if (!foldFloatTypeUnary(unionArray[i], &atanhf, infoSink, &tempConstArray[i]))
return nullptr;
break;
@@ -1451,7 +1451,7 @@
case EOpLog:
// For log(x), results are undefined if x <= 0, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && unionArray[i].getFConst() <= 0.0f)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
else if (!foldFloatTypeUnary(unionArray[i], &logf, infoSink, &tempConstArray[i]))
return nullptr;
break;
@@ -1465,7 +1465,7 @@
// For log2(x), results are undefined if x <= 0, we are choosing to set result to 0.
// And log2f is not available on some plarforms like old android, so just using log(x)/log(2) here.
if (getType().getBasicType() == EbtFloat && unionArray[i].getFConst() <= 0.0f)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
else if (!foldFloatTypeUnary(unionArray[i], &logf, infoSink, &tempConstArray[i]))
return nullptr;
else
@@ -1475,7 +1475,7 @@
case EOpSqrt:
// For sqrt(x), results are undefined if x < 0, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && unionArray[i].getFConst() < 0.0f)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
else if (!foldFloatTypeUnary(unionArray[i], &sqrtf, infoSink, &tempConstArray[i]))
return nullptr;
break;
@@ -1485,7 +1485,7 @@
// so getting the square root first using builtin function sqrt() and then taking its inverse.
// Also, for inversesqrt(x), results are undefined if x <= 0, we are choosing to set result to 0.
if (getType().getBasicType() == EbtFloat && unionArray[i].getFConst() <= 0.0f)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
else if (!foldFloatTypeUnary(unionArray[i], &sqrtf, infoSink, &tempConstArray[i]))
return nullptr;
else
@@ -1712,7 +1712,7 @@
float max = unionArrays[2][i].getFConst();
// Results are undefined if min > max.
if (min > max)
- tempConstArray[i].setFConst(0.0f);
+ UndefinedConstantFoldingError(loc, op, basicType, infoSink, &tempConstArray[i]);
else
tempConstArray[i].setFConst(gl::clamp(x, min, max));
}
@@ -1724,7 +1724,7 @@
int max = unionArrays[2][i].getIConst();
// Results are undefined if min > max.
if (min > max)
- tempConstArray[i].setIConst(0);
+ UndefinedConstantFoldingError(loc, op, basicType, infoSink, &tempConstArray[i]);
else
tempConstArray[i].setIConst(gl::clamp(x, min, max));
}
@@ -1736,7 +1736,7 @@
unsigned int max = unionArrays[2][i].getUConst();
// Results are undefined if min > max.
if (min > max)
- tempConstArray[i].setUConst(0u);
+ UndefinedConstantFoldingError(loc, op, basicType, infoSink, &tempConstArray[i]);
else
tempConstArray[i].setUConst(gl::clamp(x, min, max));
}