[PATCH] D59988: [PR41276] Generate address space cast of 'this' for objects attributed by an address space in C++

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 29 21:12:16 PDT 2019


rjmccall added inline comments.


================
Comment at: lib/CodeGen/CGClass.cpp:2025
+    ThisPtr =
+        Builder.CreatePointerBitCastOrAddrSpaceCast(This.getPointer(), NewType);
   }
----------------
Anastasia wrote:
> I am a bit unsure if `performAddrSpaceCast` should be used, but considering that we know that we are not casting a constant it should be fine?
> 
> If not any suggestions how to propagate `LangAS` of 'this' here. Some thoughts I have are:
> - Try to list the conversion up in the call stack
> - Pass `LangAS` all the way to here
I feel like `This` should just be in the right address space for the constructor at the point `EmitCXXConstructorCall` is called.  We don't expect this function to do any other semantic conversions.  Or is this necessary to handle special-case use of things like trivial default / copy constructors?


================
Comment at: lib/Sema/SemaInit.cpp:7325
+  CastKind CK = (!(VK == VK_RValue && Ty->getPointeeType().isNull()) &&
+                 Ty.getAddressSpace() != E->getType().getAddressSpace())
                     ? CK_AddressSpaceConversion
----------------
If this function is being used to do pointee qualification conversions on pointer r-values, I think you need to look at whether the pointee address spaces are different, right?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59988/new/

https://reviews.llvm.org/D59988





More information about the cfe-commits mailing list