================ @@ -103,14 +103,49 @@ using namespace std::placeholders; namespace { // Used to check correspondence between allocators and deallocators. -enum AllocationFamily { +enum AllocationFamilyKind { AF_None, AF_Malloc, AF_CXXNew, AF_CXXNewArray, AF_IfNameIndex, AF_Alloca, - AF_InnerBuffer + AF_InnerBuffer, + AF_Custom, +}; + +struct AllocationFamily { + AllocationFamilyKind Kind; + std::optional<StringRef> CustomName; + + explicit AllocationFamily(AllocationFamilyKind kind, + std::optional<StringRef> name = std::nullopt) + : Kind(kind), CustomName(name) { + assert(kind != AF_Custom || name != std::nullopt); + + // Preseve previous behavior when "malloc" class means AF_Malloc + if (Kind == AF_Malloc && CustomName) { + if (CustomName.value() == "malloc") + CustomName = std::nullopt; + else + Kind = AF_Custom; + } ---------------- steakhal wrote:
Probably I don't understand the semantics of this one. I was expecting that the `CustomName` field is only used when the `Kind` is `AF_Custom`. Yet, here it appears to be used even for `Kind == AF_Malloc`. What I originally thought that when `AF_Custom` is specified with `"malloc"`, then it should consider the case as `AF_Malloc` instead. Could you elaborate here? https://github.com/llvm/llvm-project/pull/98941 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits