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,


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to