[Mlir-commits] [mlir] [ADT] Initialize function_ref::callable (PR #216686)
Sylvestre Ledru
llvmlistbot at llvm.org
Tue Aug 18 03:05:36 PDT 2026
https://github.com/sylvestre updated https://github.com/llvm/llvm-project/pull/216686
>From 9410d0b836c0dbec37bfac8794e654446c0c791c Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru <sylvestre at debian.org>
Date: Mon, 10 Aug 2026 09:23:11 +0200
Subject: [PATCH] [MLIR] Document the OperationState properties invariant
OperationState keeps `properties` together with the `propertiesDeleter`
and `propertiesSetter` hooks: the two `function_ref`s are non-null
whenever `properties` is non-null, and they are only ever called after
checking `properties`.
Static analyzers do not see that invariant. Because an empty
`function_ref` leaves its `callable` field indeterminate, Coverity
reports 'Uninitialized scalar variable' at every site that copies an
OperationState, which is 6,436 of the 7,201 outstanding findings in the
LLVM Coverity project (nearly all of them in tblgen-generated
Op::create methods).
Rather than initializing the ADT field to appease the checker, document
the invariant and suppress the false positive here.
---
mlir/include/mlir/IR/OperationSupport.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index 942b55e8f7a76..5d8231c71469e 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -984,6 +984,10 @@ struct OperationState {
Attribute propertiesAttr;
private:
+ /// The deleter and setter are non-null whenever `properties` is, and are
+ /// only called after checking it. Coverity misses this invariant and flags
+ /// the empty `function_ref`s as uninitialized.
+ // coverity[uninit_member]
PropertyRef properties;
llvm::function_ref<void(PropertyRef)> propertiesDeleter;
llvm::function_ref<void(PropertyRef, const PropertyRef)> propertiesSetter;
More information about the Mlir-commits
mailing list