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.
This commit is contained in:
parent
14e13e757d
commit
6d35ae89c0
@ -7081,7 +7081,7 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
|
||||
switch (type.getBasicType()) {
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
return nullptr;
|
||||
case EbtInt:
|
||||
{
|
||||
switch (node->getType().getBasicType()) {
|
||||
@ -7090,7 +7090,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
|
||||
case EbtUint8: op = EOpConvUint8ToInt; break;
|
||||
case EbtInt8: op = EOpConvInt8ToInt; 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
|
||||
case EbtInt8: op = EOpConvInt8ToUint; break;
|
||||
case EbtInt: op = EOpConvIntToUint; 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
|
||||
case EbtUint8: op = EOpConvUint8ToInt8; break;
|
||||
case EbtInt: op = EOpConvIntToInt8; 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
|
||||
case EbtInt8: op = EOpConvInt8ToUint8; break;
|
||||
case EbtInt: op = EOpConvIntToUint8; break;
|
||||
case EbtUint: op = EOpConvUintToUint8; break;
|
||||
default: assert(0);
|
||||
default:
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -7142,7 +7150,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
|
||||
case EbtUint8: op = EOpConvUint8ToFloat; break;
|
||||
case EbtInt: op = EOpConvIntToFloat; break;
|
||||
case EbtUint: op = EOpConvUintToFloat; break;
|
||||
default: assert(0);
|
||||
default:
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -7154,7 +7164,9 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
|
||||
case EbtUint8: op = EOpConvUint8ToFloat16; break;
|
||||
case EbtInt: op = EOpConvIntToFloat16; break;
|
||||
case EbtUint: op = EOpConvUintToFloat16; break;
|
||||
default: assert(0);
|
||||
default:
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user