[Mlir-commits] [mlir] 923230d - [mlir] Add missing cast functions to mlir namespace

Rahul Kayaith llvmlistbot at llvm.org
Mon Mar 27 11:13:06 PDT 2023


Author: Rahul Kayaith
Date: 2023-03-27T14:12:57-04:00
New Revision: 923230d45eb5cb0278e5b198c4f840bfaac50abc

URL: https://github.com/llvm/llvm-project/commit/923230d45eb5cb0278e5b198c4f840bfaac50abc
DIFF: https://github.com/llvm/llvm-project/commit/923230d45eb5cb0278e5b198c4f840bfaac50abc.diff

LOG: [mlir] Add missing cast functions to mlir namespace

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D146843

Added: 
    

Modified: 
    mlir/include/mlir/Support/LLVM.h
    mlir/unittests/IR/TypeTest.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Support/LLVM.h b/mlir/include/mlir/Support/LLVM.h
index 7acf97b5a2531..216de42ad810e 100644
--- a/mlir/include/mlir/Support/LLVM.h
+++ b/mlir/include/mlir/Support/LLVM.h
@@ -96,12 +96,14 @@ class SMRange;
 namespace mlir {
 // Casting operators.
 using llvm::cast;
+using llvm::cast_if_present;
 using llvm::cast_or_null;
 using llvm::dyn_cast;
 using llvm::dyn_cast_if_present;
 using llvm::dyn_cast_or_null;
 using llvm::isa;
 using llvm::isa_and_nonnull;
+using llvm::isa_and_present;
 
 // String types
 using llvm::SmallString;

diff  --git a/mlir/unittests/IR/TypeTest.cpp b/mlir/unittests/IR/TypeTest.cpp
index 462cb185343d2..1bb9d077d8ed5 100644
--- a/mlir/unittests/IR/TypeTest.cpp
+++ b/mlir/unittests/IR/TypeTest.cpp
@@ -50,7 +50,7 @@ TEST(Type, Casting) {
 
   EXPECT_TRUE(isa<IntegerType>(intTy));
   EXPECT_FALSE(isa<FunctionType>(intTy));
-  EXPECT_FALSE(llvm::isa_and_present<IntegerType>(nullTy));
+  EXPECT_FALSE(isa_and_present<IntegerType>(nullTy));
   EXPECT_TRUE(isa<MiddleType>(middleTy));
   EXPECT_FALSE(isa<LeafType>(middleTy));
   EXPECT_TRUE(isa<MiddleType>(leafTy));
@@ -59,9 +59,8 @@ TEST(Type, Casting) {
 
   EXPECT_TRUE(static_cast<bool>(dyn_cast<IntegerType>(intTy)));
   EXPECT_FALSE(static_cast<bool>(dyn_cast<FunctionType>(intTy)));
-  EXPECT_FALSE(static_cast<bool>(llvm::cast_if_present<FunctionType>(nullTy)));
-  EXPECT_FALSE(
-      static_cast<bool>(llvm::dyn_cast_if_present<IntegerType>(nullTy)));
+  EXPECT_FALSE(static_cast<bool>(cast_if_present<FunctionType>(nullTy)));
+  EXPECT_FALSE(static_cast<bool>(dyn_cast_if_present<IntegerType>(nullTy)));
 
   EXPECT_EQ(8u, cast<IntegerType>(intTy).getWidth());
 }


        


More information about the Mlir-commits mailing list