[libcxx-commits] [libcxx] Add `_LIBCPP_PLACEMENT_NEW_DEFINED` macro to allow for user defined placement new operators (PR #70538)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 30 20:59:56 PDT 2023


ldionne wrote:

Reopening, I think there's something I don't understand here.

> Clang treats the reserved placement new as an intrinsic as long as it is declared within the TU.
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprCXX.cpp#L1587 for reference.
This avoids generation of a function call and avoids needing to include <new> to ensure what effectively should be a language feature in C++.

If you `#include <new>`, then placement-new is declared inside the TU and so Clang should treat it as an intrinsic, no? Is that not what happens?

I don't think it is worth doing something about the "compilation time issue", however if we do something that pessimizes how Clang handles our stdlib-declared placement new, then it is probably reasonable to do something about *that*.

https://github.com/llvm/llvm-project/pull/70538


More information about the libcxx-commits mailing list