[all-commits] [llvm/llvm-project] f156b5: [LLVM][Casting.h] Update dyn_cast machinery to pro...

Aman LaChapelle via All-commits all-commits at lists.llvm.org
Wed May 11 21:15:24 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f156b51aecc676a9051136f6f5cb74e37dd574d1
      https://github.com/llvm/llvm-project/commit/f156b51aecc676a9051136f6f5cb74e37dd574d1
  Author: bzcheeseman <12992886+bzcheeseman at users.noreply.github.com>
  Date:   2022-05-12 (Thu, 12 May 2022)

  Changed paths:
    M llvm/include/llvm/Support/Casting.h
    M llvm/unittests/Support/Casting.cpp

  Log Message:
  -----------
  [LLVM][Casting.h] Update dyn_cast machinery to provide more control over how the casting is performed.

This patch expands the expressive capability of the casting utilities in LLVM by introducing several levels of configurability. By creating modular CastInfo classes we can enable projects like MLIR that need more fine-grained control over how a cast is actually performed to retain that control, while making it easy to express the easy cases (like a checked pointer to pointer cast).

The current implementation of Casting.h doesn't make it clear where the entry points for customizing the cast behavior are, so part of the motivation for this patch is adding that documentation. Another part of the motivation is to support using LLVM RTTI with a wider set of use cases, such as nullable value to value casts, or pointer to value casts (as in MLIR).

Reviewed By: lattner, rriddle

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




More information about the All-commits mailing list