From: Marco Antognini Date: Wed, 17 Jul 2019 08:52:09 +0000 (+0000) Subject: [OpenCL][Sema] Minor refactoring and constraint checking X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14552d6ffe7b2fa7c9101920ad59141b034fd14b;p=clang [OpenCL][Sema] Minor refactoring and constraint checking Summary: Simplify code a bit and add assertion to address post-landing comments from D64083. Subscribers: yaxunl, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64804 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@366306 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index df8638a013..cdca2e8cac 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -4216,17 +4216,12 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, 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(LHSType) && "BlockPointerType expected"); - assert(isa(RHSType) && "BlockPointerType expected"); - LangAS AddrSpaceL = - LHSType->getAs()->getPointeeType().getAddressSpace(); + ToType->castAs()->getPointeeType().getAddressSpace(); LangAS AddrSpaceR = - RHSType->getAs()->getPointeeType().getAddressSpace(); + FromType->castAs()->getPointeeType().getAddressSpace(); + assert(Qualifiers::isAddressSpaceSupersetOf(AddrSpaceL, AddrSpaceR) && + "Invalid cast"); CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast; From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,