[Mlir-commits] [mlir] 8bc1ce0 - Use dyn_cast_or_null instead of dyn_cast in FunctionLike::verifyTrait (NFC)

Mehdi Amini llvmlistbot at llvm.org
Sat Jun 12 14:06:29 PDT 2021


Author: Mehdi Amini
Date: 2021-06-12T20:08:37Z
New Revision: 8bc1ce0f61da0b2d0c3a17aec898df7001336ea5

URL: https://github.com/llvm/llvm-project/commit/8bc1ce0f61da0b2d0c3a17aec898df7001336ea5
DIFF: https://github.com/llvm/llvm-project/commit/8bc1ce0f61da0b2d0c3a17aec898df7001336ea5.diff

LOG: Use dyn_cast_or_null instead of dyn_cast in FunctionLike::verifyTrait (NFC)

This is making the verifier more tolerant to cases where a "null"
Attribute would be inserted in the array of func arguments/results
attributes.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h
index 21d6e37243128..c081fb24bf268 100644
--- a/mlir/include/mlir/IR/FunctionSupport.h
+++ b/mlir/include/mlir/IR/FunctionSupport.h
@@ -522,7 +522,8 @@ LogicalResult FunctionLike<ConcreteType>::verifyTrait(Operation *op) {
              << allArgAttrs.size() << ", but expected " << numArgs;
     }
     for (unsigned i = 0; i != numArgs; ++i) {
-      DictionaryAttr argAttrs = allArgAttrs[i].dyn_cast<DictionaryAttr>();
+      DictionaryAttr argAttrs =
+          allArgAttrs[i].dyn_cast_or_null<DictionaryAttr>();
       if (!argAttrs) {
         return funcOp.emitOpError() << "expects argument attribute dictionary "
                                        "to be a DictionaryAttr, but got `"
@@ -555,7 +556,8 @@ LogicalResult FunctionLike<ConcreteType>::verifyTrait(Operation *op) {
              << allResultAttrs.size() << ", but expected " << numResults;
     }
     for (unsigned i = 0; i != numResults; ++i) {
-      DictionaryAttr resultAttrs = allResultAttrs[i].dyn_cast<DictionaryAttr>();
+      DictionaryAttr resultAttrs =
+          allResultAttrs[i].dyn_cast_or_null<DictionaryAttr>();
       if (!resultAttrs) {
         return funcOp.emitOpError() << "expects result attribute dictionary "
                                        "to be a DictionaryAttr, but got `"


        


More information about the Mlir-commits mailing list