[cfe-dev] Call a constructor on a pointer in Sema
John McCall via cfe-dev
cfe-dev at lists.llvm.org
Thu Jun 29 23:45:36 PDT 2017
> On Jun 21, 2017, at 1:53 PM, Brian Chak via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> I'm trying to create a wrapper function that takes a pointer and essentially calls placement new on it. Is it possible to generate AST for this in Sema instead of generating llvm directly in CodeGen?
>
> I cannot just use placement new because it is not implicitly defined and users may write their own definition of it.
Users are not allowed to override the reserved placement new function, i.e. the one that just takes a void*, and Clang will not actually call it if they try. But you're right that it's not implicitly declared like the non-placement operator new is.
It wouldn't be completely ridiculous to allow CXXNewExpr to not contain an operator new, but you could probably also just fake one up that will satisfy isReservedGlobalPlacementOperator(). If this is destined to go in-tree, though, there might be better options.
John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170630/18ac162b/attachment.html>
More information about the cfe-dev
mailing list