[clang] [RFC] Initial implementation of P2719 (PR #113510)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 25 14:05:12 PDT 2025
================
@@ -2527,6 +2527,32 @@ class FunctionDecl : public DeclaratorDecl,
/// If this function is an allocation/deallocation function that takes
/// the `std::nothrow_t` tag, return true through IsNothrow,
bool isReplaceableGlobalAllocationFunction(
+ std::optional<unsigned> *AlignmentParam = nullptr,
+ bool *IsNothrow = nullptr) const {
+ if (isTypeAwareOperatorNewOrDelete())
+ return false;
+ return isUsableAsGlobalAllocationFunctionInConstantEvaluation(
+ AlignmentParam, IsNothrow);
+ }
+
+ /// Determines whether this function is one of the replaceable global
+ /// allocation functions described in isReplaceableGlobalAllocationFunction,
+ /// or is a function that may be treated as such during constant evaluation.
+ /// This adds support for potentially templated type aware global allocation
+ /// functions of the form:
+ /// void *operator new(type-identity, std::size_t, std::align_val_t)
+ /// void *operator new(type-identity, std::size_t, std::align_val_t, const std::nothrow_t &) noexcept;
+ /// void *operator new[](type-identity, std::size_t, std::align_val_t)
+ /// void *operator new[](type-identity, std::size_t, std::align_val_t, const std::nothrow_t &) noexcept;
+ /// void operator delete(type-identity, void*, std::size_t, std::align_val_t) noexcept;
----------------
ojhunt wrote:
clang-format wraps these as if they're comments which I've been unwrapping for now pending what the correct format should be.
https://github.com/llvm/llvm-project/pull/113510
More information about the cfe-commits
mailing list