[all-commits] [llvm/llvm-project] bb63d2: [NFC][mlir] Add support for llvm style casting for...

Ralender via All-commits all-commits at lists.llvm.org
Wed Aug 24 09:33:21 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bb63d249f8612f87e819071663d81f516a2bec74
      https://github.com/llvm/llvm-project/commit/bb63d249f8612f87e819071663d81f516a2bec74
  Author: Tyker <tyker1 at outlook.com>
  Date:   2022-08-24 (Wed, 24 Aug 2022)

  Changed paths:
    M mlir/include/mlir/IR/Types.h
    M mlir/unittests/IR/CMakeLists.txt
    A mlir/unittests/IR/TypeTest.cpp

  Log Message:
  -----------
  [NFC][mlir] Add support for llvm style casting for mlir types

Note:
when operating on a Type hierarchy with LeafType inheriting from MiddleType which inherits from mlir::Type.
calling LeafType::classof(MiddleType) will always return false.
because classof call the static getTypeID from its parent instead of the dynamic Type::getTypeID
so classof in this context will check if the TypeID of LeafType is the same as the TypeID of MiddleType which is always false.
It is bypassed in this commit inside CastInfo<To, From>::isPossible by calling classof with an mlir::Type.
but other unsuspecting users of LeafType::classof(MiddleType) would still get an incorrect result.




More information about the All-commits mailing list