Call a constructor on a pointer in Sema

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Call a constructor on a pointer in Sema

Xin Wang via cfe-dev
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.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Call a constructor on a pointer in Sema

Xin Wang via cfe-dev
On Jun 21, 2017, at 1:53 PM, Brian Chak via cfe-dev <[hidden email]> 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.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...