[Mlir-commits] [mlir] [MLIR] Sprinkle extra asserts in OperationSupport.h (PR #90465)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Apr 29 06:08:17 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Johannes de Fine Licht (definelicht)

<details>
<summary>Changes</summary>

Should hopefully help shave some minutes off developer debugging time in the future.

---
Full diff: https://github.com/llvm/llvm-project/pull/90465.diff


1 Files Affected:

- (modified) mlir/include/mlir/IR/OperationSupport.h (+6-1) 


``````````diff
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index cdb75a3777ad80..b3c3401d51b506 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1039,6 +1039,8 @@ struct OperationState {
 
   /// Add an attribute with the specified name.
   void addAttribute(StringAttr name, Attribute attr) {
+    assert(name && "attribute name cannot be null");
+    assert(attr && "attribute cannot be null");
     attributes.append(name, attr);
   }
 
@@ -1047,7 +1049,10 @@ struct OperationState {
     attributes.append(newAttributes);
   }
 
-  void addSuccessors(Block *successor) { successors.push_back(successor); }
+  void addSuccessors(Block *successor) {
+    assert(successor && "successor cannot be null");
+    successors.push_back(successor);
+  }
   void addSuccessors(BlockRange newSuccessors);
 
   /// Create a region that should be attached to the operation.  These regions

``````````

</details>


https://github.com/llvm/llvm-project/pull/90465


More information about the Mlir-commits mailing list