[PATCH] D64804: [OpenCL][Sema] Minor refactoring and constraint checking
Marco Antognini via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 16 09:05:15 PDT 2019
mantognini created this revision.
Herald added subscribers: cfe-commits, Anastasia, yaxunl.
Herald added a project: clang.
Simplify code a bit and add assertion to address post-landing comments
from D64083 <https://reviews.llvm.org/D64083>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64804
Files:
clang/lib/Sema/SemaExprCXX.cpp
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4216,17 +4216,12 @@
break;
case ICK_Block_Pointer_Conversion: {
- QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
- QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
-
- // Assumptions based on Sema::IsBlockPointerConversion.
- assert(isa<BlockPointerType>(LHSType) && "BlockPointerType expected");
- assert(isa<BlockPointerType>(RHSType) && "BlockPointerType expected");
-
LangAS AddrSpaceL =
- LHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace();
+ ToType->castAs<BlockPointerType>()->getPointeeType().getAddressSpace();
LangAS AddrSpaceR =
- RHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace();
+ FromType->castAs<BlockPointerType>()->getPointeeType().getAddressSpace();
+ assert(Qualifiers::isAddressSpaceSupersetOf(AddrSpaceL, AddrSpaceR) &&
+ "Invalid cast");
CastKind Kind =
AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64804.210115.patch
Type: text/x-patch
Size: 1280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190716/ae2187d8/attachment.bin>
More information about the cfe-commits
mailing list