[all-commits] [llvm/llvm-project] c75870: [LLVM][Casting.h] Add ForwardToPointerCast trait
Aman LaChapelle via All-commits
all-commits at lists.llvm.org
Fri May 13 15:49:04 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c7587080188e1f46ddf8b8274e99d4481361d5dc
https://github.com/llvm/llvm-project/commit/c7587080188e1f46ddf8b8274e99d4481361d5dc
Author: bzcheeseman <aman.lachapelle at gmail.com>
Date: 2022-05-13 (Fri, 13 May 2022)
Changed paths:
M llvm/include/llvm/Support/Casting.h
Log Message:
-----------
[LLVM][Casting.h] Add ForwardToPointerCast trait
Addresses use cases in Clang/MLIR that need pointer-to-pointer, reference-to-reference, and value-to-value casts from/to the same types. This should reduce boilerplate by allowing the user to simply specify the pointer cast and forward the reference cast directly to the pointer cast.
This cast trait DOES NOT implement `castFailed` and `doCastIfPossible` because in the general case doing so could result in a nullptr dereference. Users can use `NullableValueCastFailed` and `DefaultDoCastIfPossible` as desired for those cases where `nullptr` is acceptable.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D125576
More information about the All-commits
mailing list