[LLVM][Casting.h] Don't create a temporary while casting.
authorbzcheeseman <aman.lachapelle@gmail.com>
Thu, 12 May 2022 17:38:49 +0000 (13:38 -0400)
committerbzcheeseman <aman.lachapelle@gmail.com>
Fri, 13 May 2022 03:11:02 +0000 (23:11 -0400)
commit0be41ed5bb57aded4e8ca1c6a8d22b7830c8f2fc
tree0128871ca62a515740d9d40d263a511b1b9ea097
parent0ca2b93cc2864ad33937f21351f0d34dd5819aa2
[LLVM][Casting.h] Don't create a temporary while casting.

C-style casting can create a temporary when compiled by a C++ compiler, which was emitting a warning casting a reference to another reference. We can't use C++-style casting directly because it doesn't always work with incomplete types. In order to support the current use-cases, for references we switch to pointer space to perform the cast.

Reviewed By: qiongsiwu1

Differential Revision: https://reviews.llvm.org/D125482
llvm/include/llvm/Support/Casting.h
llvm/unittests/Support/Casting.cpp