diff options
author | Marco Antognini <marco.antognini@arm.com> | 2019-07-17 08:52:09 +0000 |
---|---|---|
committer | Marco Antognini <marco.antognini@arm.com> | 2019-07-17 08:52:09 +0000 |
commit | 9eb95903da4575b3b95d1a743d48e51bb5026ccd (patch) | |
tree | a9301e7a9b22dcc2f6a1cddd0709e6f8bd5699bd /clang/lib | |
parent | 96627215729080f42488185b29e03e73cee08204 (diff) | |
download | bcm5719-llvm-9eb95903da4575b3b95d1a743d48e51bb5026ccd.tar.gz bcm5719-llvm-9eb95903da4575b3b95d1a743d48e51bb5026ccd.zip |
[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
llvm-svn: 366306
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index df8638a0136..cdca2e8cac6 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/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<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, |