summaryrefslogtreecommitdiff
path: root/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2018-11-16 16:22:56 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2018-11-16 16:22:56 +0000
commitb6508aa4110621b4c5441dd67013cee4ec0d3036 (patch)
tree1652c7db8cd5af1be6079f8972b42f7b6a526615 /lib/AST/Expr.cpp
parent59e40fbc67abf5f59b408d83bab2e33e1fe0eb17 (diff)
downloadclang-b6508aa4110621b4c5441dd67013cee4ec0d3036.tar.gz
[OpenCL] Enable address spaces for references in C++
Added references to the addr spaces deduction and enabled CL2.0 features (program scope variables and storage class qualifiers) to work in C++ mode too. Fixed several address space conversion issues in CodeGen for references. Differential Revision: https://reviews.llvm.org/D53764 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r--lib/AST/Expr.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index b811b22239..2e26500862 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1634,13 +1634,18 @@ bool CastExpr::CastConsistency() const {
assert(getSubExpr()->getType()->isFunctionType());
goto CheckNoBasePath;
- case CK_AddressSpaceConversion:
- assert(getType()->isPointerType() || getType()->isBlockPointerType());
- assert(getSubExpr()->getType()->isPointerType() ||
- getSubExpr()->getType()->isBlockPointerType());
- assert(getType()->getPointeeType().getAddressSpace() !=
- getSubExpr()->getType()->getPointeeType().getAddressSpace());
- LLVM_FALLTHROUGH;
+ case CK_AddressSpaceConversion: {
+ auto Ty = getType();
+ auto SETy = getSubExpr()->getType();
+ assert(getValueKindForType(Ty) == Expr::getValueKindForType(SETy));
+ if (!isGLValue())
+ Ty = Ty->getPointeeType();
+ if (!isGLValue())
+ SETy = SETy->getPointeeType();
+ assert(!Ty.isNull() && !SETy.isNull() &&
+ Ty.getAddressSpace() != SETy.getAddressSpace());
+ goto CheckNoBasePath;
+ }
// These should not have an inheritance path.
case CK_Dynamic:
case CK_ToUnion: