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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Apr 30 01:00:08 PDT 2024


Author: Johannes de Fine Licht
Date: 2024-04-30T10:00:04+02:00
New Revision: 2464c1c153285bbabf1df4a61f1975903ffbe70e

URL: https://github.com/llvm/llvm-project/commit/2464c1c153285bbabf1df4a61f1975903ffbe70e
DIFF: https://github.com/llvm/llvm-project/commit/2464c1c153285bbabf1df4a61f1975903ffbe70e.diff

LOG: [MLIR] Sprinkle extra asserts in OperationSupport.h (#90465)

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

Added: 
    

Modified: 
    mlir/include/mlir/IR/OperationSupport.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index cdb75a3777ad80..e661bb87a27ed0 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1037,8 +1037,11 @@ struct OperationState {
     addAttribute(StringAttr::get(getContext(), name), attr);
   }
 
-  /// Add an attribute with the specified name.
+  /// Add an attribute with the specified name. `name` and `attr` must not be
+  /// null.
   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 +1050,11 @@ struct OperationState {
     attributes.append(newAttributes);
   }
 
-  void addSuccessors(Block *successor) { successors.push_back(successor); }
+  /// Adds a successor to the operation sate. `successor` must not be null.
+  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


        


More information about the Mlir-commits mailing list