[Mlir-commits] [mlir] 2ec510f - [mlir] Add Type::isa_and_nonnull

Markus Böck llvmlistbot at llvm.org
Thu Jul 28 13:41:58 PDT 2022


Author: Markus Böck
Date: 2022-07-28T22:41:46+02:00
New Revision: 2ec510f1135de3c43b6e6d518c8869bd1601ef90

URL: https://github.com/llvm/llvm-project/commit/2ec510f1135de3c43b6e6d518c8869bd1601ef90
DIFF: https://github.com/llvm/llvm-project/commit/2ec510f1135de3c43b6e6d518c8869bd1601ef90.diff

LOG: [mlir] Add Type::isa_and_nonnull

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index d19f1feaf51d7..cb2328ef3f033 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -98,6 +98,8 @@ class Type {
   bool isa() const;
   template <typename First, typename Second, typename... Rest>
   bool isa() const;
+  template <typename First, typename... Rest>
+  bool isa_and_nonnull() const;
   template <typename U>
   U dyn_cast() const;
   template <typename U>
@@ -259,6 +261,11 @@ bool Type::isa() const {
   return isa<First>() || isa<Second, Rest...>();
 }
 
+template <typename First, typename... Rest>
+bool Type::isa_and_nonnull() const {
+  return impl && isa<First, Rest...>();
+}
+
 template <typename U>
 U Type::dyn_cast() const {
   return isa<U>() ? U(impl) : U(nullptr);


        


More information about the Mlir-commits mailing list