[PATCH] D68781: [OpenCL] Fix address space for const method call from nonconst
Sven van Haastregt via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 05:15:18 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG82888b78d47e: [OpenCL] Fix address space for const method call from nonconst (PR43145) (authored by svenvh).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68781/new/
https://reviews.llvm.org/D68781
Files:
clang/lib/Sema/SemaOverload.cpp
clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
Index: clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
===================================================================
--- clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -203,3 +203,14 @@
// IMPL: [[C2GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C2GEN]] to i8 addrspace(4)*
// IMPL: [[C1GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C1GEN]] to i8 addrspace(4)*
// IMPL: call void @llvm.memcpy.p4i8.p4i8.i32(i8 addrspace(4)* {{.*}}[[C2GENVOID]], i8 addrspace(4)* {{.*}}[[C1GENVOID]]
+
+// Test that calling a const method from a non-const method does not crash Clang.
+class ConstAndNonConstMethod {
+public:
+ void DoConst() const {
+ }
+
+ void DoNonConst() {
+ DoConst();
+ }
+};
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5370,7 +5370,10 @@
if (!Context.hasSameType(From->getType(), DestType)) {
CastKind CK;
- if (FromRecordType.getAddressSpace() != DestType.getAddressSpace())
+ QualType PteeTy = DestType->getPointeeType();
+ LangAS DestAS =
+ PteeTy.isNull() ? DestType.getAddressSpace() : PteeTy.getAddressSpace();
+ if (FromRecordType.getAddressSpace() != DestAS)
CK = CK_AddressSpaceConversion;
else
CK = CK_NoOp;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68781.227697.patch
Type: text/x-patch
Size: 1401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191104/1c99a514/attachment.bin>
More information about the cfe-commits
mailing list