r366306 - [OpenCL][Sema] Minor refactoring and constraint checking
Marco Antognini via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 17 01:52:09 PDT 2019
Author: mantognini
Date: Wed Jul 17 01:52:09 2019
New Revision: 366306
URL: http://llvm.org/viewvc/llvm-project?rev=366306&view=rev
Log:
[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
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=366306&r1=366305&r2=366306&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 17 01:52:09 2019
@@ -4216,17 +4216,12 @@ Sema::PerformImplicitConversion(Expr *Fr
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,
More information about the cfe-commits
mailing list