From 923230d45eb5cb0278e5b198c4f840bfaac50abc Mon Sep 17 00:00:00 2001 From: Rahul Kayaith Date: Fri, 24 Mar 2023 14:25:18 -0400 Subject: [PATCH] [mlir] Add missing cast functions to mlir namespace Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D146843 --- mlir/include/mlir/Support/LLVM.h | 2 ++ mlir/unittests/IR/TypeTest.cpp | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mlir/include/mlir/Support/LLVM.h b/mlir/include/mlir/Support/LLVM.h index 7acf97b..216de42a 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 462cb18..1bb9d07 100644 --- a/mlir/unittests/IR/TypeTest.cpp +++ b/mlir/unittests/IR/TypeTest.cpp @@ -50,7 +50,7 @@ TEST(Type, Casting) { EXPECT_TRUE(isa(intTy)); EXPECT_FALSE(isa(intTy)); - EXPECT_FALSE(llvm::isa_and_present(nullTy)); + EXPECT_FALSE(isa_and_present(nullTy)); EXPECT_TRUE(isa(middleTy)); EXPECT_FALSE(isa(middleTy)); EXPECT_TRUE(isa(leafTy)); @@ -59,9 +59,8 @@ TEST(Type, Casting) { EXPECT_TRUE(static_cast(dyn_cast(intTy))); EXPECT_FALSE(static_cast(dyn_cast(intTy))); - EXPECT_FALSE(static_cast(llvm::cast_if_present(nullTy))); - EXPECT_FALSE( - static_cast(llvm::dyn_cast_if_present(nullTy))); + EXPECT_FALSE(static_cast(cast_if_present(nullTy))); + EXPECT_FALSE(static_cast(dyn_cast_if_present(nullTy))); EXPECT_EQ(8u, cast(intTy).getWidth()); } -- 2.7.4