NoQ added a comment.

In D103750#2803516 <https://reviews.llvm.org/D103750#2803516>, @RedDocMD wrote:

> In D103750#2803499 <https://reviews.llvm.org/D103750#2803499>, @NoQ wrote:
>
>> Ugh, this entire `checkBind` hack was so unexpected that I didn't even 
>> recognize `evalCall`. What prevents you from doing everything in `evalCall`? 
>> No state traits, no nothing, just directly take the this-region and attach 
>> the value to it?
>
> Because in `evalCall`, I don't have access to the `ThisRegion`.

You do have access to it. That's how C++ works: the call constructs the value 
directly into the target this-region. In code

  auto a = std::make_unique<int>(100)

it is known even before `std::make_unique` is invoked (i.e., even in 
`checkPreCall`) that the this-region for the call is going to be `a`. Because 
it's up to the call to invoke the constructor of the external object, and you 
can't invoke a constructor if you don't have a `this` to pass into it. //You 
cannot ever have an object and not have `this`.
//
Even if it wasn't for RVO, you would have known the temporary region in which 
the smart pointer would originally reside.

This was the whole point of the CFG work described in 
https://www.youtube.com/watch?v=4n3l-ZcDJNY

You're looking in the wrong place though, as `std::make_unique` returns the 
structure by value (aka prvalue), so the value of the expression, even if 
available before the call, was never going to be `this` (which would have been 
the corresponding glvalue). What you're looking for is 
`CallEvent::getReturnValueUnderConstruction()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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

Reply via email to