[clang] [Clang][Sema]: Allow copy constructor side effects (PR #81127)
Vinayak Dev via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 25 07:58:05 PST 2024
vinayakdsci wrote:
@cor3ntin gentle ping. How exactly should I proceed? copy elision was made mandatory in C++17, so wouldn't a warning for C++ < 17 be allowable?
I am very happy to implement any suggestions you have for this PR, but I am unable to get the code to work for C++ < 17 because the constructors are not marked elidable in the code for these standards.
Specifically in the case where the class object is initialized by an '=' sign instead of an explicit argument being passed. As the RHS of the '=' is different from a `CXXRecordDecl`, `isTemporaryObject()` returns false and thus sets the constructor as non-elidable. This is where I am not sure on how to proceed, as changing this behavior breaks a number of assertions in the code path followed while compiling the source program. Either I could check if the RHS of the assignment is an rvalue, and then add an OR condition to set Elidable for the constructor to true. However, _whenever_ the constructor is elidable, the codegen emits _directly_, and expects an aggregate type to passed in, which is not true for a scalar such as an `int`.
Also, this would involve a conversion process in the code?
I would really appreciate pointers on how to solve this problem, and how to improve this PR too.
Thanks!
https://github.com/llvm/llvm-project/pull/81127
More information about the cfe-commits
mailing list