[llvm] [SPIRV] Fix code quality issues. (PR #152005)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 5 04:16:50 PDT 2025
================
@@ -893,9 +893,11 @@ Type *SPIRVEmitIntrinsics::deduceNestedTypeHelper(
bool Change = false;
for (unsigned i = 0; i < U->getNumOperands(); ++i) {
Value *Op = U->getOperand(i);
- Type *OpTy = Op->getType();
- Type *Ty = OpTy;
+ Type *OpTy = nullptr;
+ Type *Ty = nullptr;
if (Op) {
+ OpTy = Op->getType();
+ Ty = OpTy;
----------------
Keenuts wrote:
This looks wrong.
-> We use `U->getNumOperands()` and then index using this bounded value. Meaning if we get a `nullptr` operand, something is wrong.
I would maybe `assert(OpTy)`, but setting `Ty` to nullptr as-is means we expect some operands to be null and that we could push nullptr to `Tys`, which seems wrong.
https://github.com/llvm/llvm-project/pull/152005
More information about the llvm-commits
mailing list