Commit 6d35ae89 by Ryan Harrison

Return nullptr after assert to avoid uninitialized variables

In the current version of the code on non-debug builds these cases will fallthrough, since assert is a no-op, and eventually make a call passing in |op| which hasn't been initialized. clang is currently throwing a warning about this behaviour when integrating downstream. This patch changes the behaviour, so that in any branch that has an assert now has a return nullptr, to indicate failure after it and avoid the uninitialized variable usage.
parent 14e13e75
...@@ -7081,7 +7081,7 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -7081,7 +7081,7 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
switch (type.getBasicType()) { switch (type.getBasicType()) {
default: default:
assert(0); assert(0);
break; return nullptr;
case EbtInt: case EbtInt:
{ {
switch (node->getType().getBasicType()) { switch (node->getType().getBasicType()) {
...@@ -7090,7 +7090,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -7090,7 +7090,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
case EbtUint8: op = EOpConvUint8ToInt; break; case EbtUint8: op = EOpConvUint8ToInt; break;
case EbtInt8: op = EOpConvInt8ToInt; break; case EbtInt8: op = EOpConvInt8ToInt; break;
case EbtUint: op = EOpConvUintToInt; break; case EbtUint: op = EOpConvUintToInt; break;
default: assert(0); default:
assert(0);
return nullptr;
} }
} }
...@@ -7104,7 +7106,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -7104,7 +7106,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
case EbtInt8: op = EOpConvInt8ToUint; break; case EbtInt8: op = EOpConvInt8ToUint; break;
case EbtInt: op = EOpConvIntToUint; break; case EbtInt: op = EOpConvIntToUint; break;
case EbtUint: op = EOpConvUintToInt8; break; case EbtUint: op = EOpConvUintToInt8; break;
default: assert(0); default:
assert(0);
return nullptr;
} }
} }
...@@ -7118,7 +7122,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -7118,7 +7122,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
case EbtUint8: op = EOpConvUint8ToInt8; break; case EbtUint8: op = EOpConvUint8ToInt8; break;
case EbtInt: op = EOpConvIntToInt8; break; case EbtInt: op = EOpConvIntToInt8; break;
case EbtUint: op = EOpConvUintToInt8; break; case EbtUint: op = EOpConvUintToInt8; break;
default: assert(0); default:
assert(0);
return nullptr;
} }
} }
...@@ -7130,7 +7136,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -7130,7 +7136,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
case EbtInt8: op = EOpConvInt8ToUint8; break; case EbtInt8: op = EOpConvInt8ToUint8; break;
case EbtInt: op = EOpConvIntToUint8; break; case EbtInt: op = EOpConvIntToUint8; break;
case EbtUint: op = EOpConvUintToUint8; break; case EbtUint: op = EOpConvUintToUint8; break;
default: assert(0); default:
assert(0);
return nullptr;
} }
} }
break; break;
...@@ -7142,7 +7150,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -7142,7 +7150,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
case EbtUint8: op = EOpConvUint8ToFloat; break; case EbtUint8: op = EOpConvUint8ToFloat; break;
case EbtInt: op = EOpConvIntToFloat; break; case EbtInt: op = EOpConvIntToFloat; break;
case EbtUint: op = EOpConvUintToFloat; break; case EbtUint: op = EOpConvUintToFloat; break;
default: assert(0); default:
assert(0);
return nullptr;
} }
} }
break; break;
...@@ -7154,7 +7164,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -7154,7 +7164,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
case EbtUint8: op = EOpConvUint8ToFloat16; break; case EbtUint8: op = EOpConvUint8ToFloat16; break;
case EbtInt: op = EOpConvIntToFloat16; break; case EbtInt: op = EOpConvIntToFloat16; break;
case EbtUint: op = EOpConvUintToFloat16; break; case EbtUint: op = EOpConvUintToFloat16; break;
default: assert(0); default:
assert(0);
return nullptr;
} }
} }
break; break;
......
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