[clang] [AllocToken] Enable alloc token instrumentation for size-returning functions (PR #168840)

2025-11-20 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh created https://github.com/llvm/llvm-project/pull/168840 Consider a newly added "malloc_span" attribute in the allocation token instrumentation to ensure that __size_returning_new variants are correctly identified as memory allocation functions. Adjust the allocati

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-19 Thread Aleksandr Nogikh via cfe-commits
@@ -1839,6 +1839,70 @@ static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { RestrictAttr(S.Context, AL, DeallocE, DeallocPtrIdx)); } +bool Sema::CheckSpanLikeType(const AttributeCommonInfo &CI, + const QualType

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-19 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh updated https://github.com/llvm/llvm-project/pull/167010 >From 2d0bf7d9a584cefda1e7a9435e345e13c24e40ed Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 17 Oct 2025 18:05:36 +0200 Subject: [PATCH 01/20] [Clang] Introduce malloc_span attribute The "malloc"

[clang] [llvm] [AllocToken] Fix and clarify -falloc-token-max=0 (PR #168689)

2025-11-19 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh commented: LGTM https://github.com/llvm/llvm-project/pull/168689 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-19 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh edited https://github.com/llvm/llvm-project/pull/167010 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-19 Thread Aleksandr Nogikh via cfe-commits
@@ -1839,6 +1839,41 @@ static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { RestrictAttr(S.Context, AL, DeallocE, DeallocPtrIdx)); } +static bool isSpanLikeType(const QualType &Ty) { + // Check that the type is a plain record with one fie

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-19 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh updated https://github.com/llvm/llvm-project/pull/167010 >From e0fa07d42042a391fc92c71e6e2e378dd58a775b Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 17 Oct 2025 18:05:36 +0200 Subject: [PATCH 01/13] [Clang] Introduce malloc_span attribute The "malloc"

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-14 Thread Aleksandr Nogikh via cfe-commits
@@ -1839,6 +1839,41 @@ static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { RestrictAttr(S.Context, AL, DeallocE, DeallocPtrIdx)); } +static bool isSpanLikeType(const QualType &Ty) { a-nogikh wrote: Renamed to `checkSpanL

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-12 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh updated https://github.com/llvm/llvm-project/pull/167010 >From e0fa07d42042a391fc92c71e6e2e378dd58a775b Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 17 Oct 2025 18:05:36 +0200 Subject: [PATCH 1/2] [Clang] Introduce malloc_span attribute The "malloc" at

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-11 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh edited https://github.com/llvm/llvm-project/pull/167010 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Allow malloc for functions returning structs (PR #165433)

2025-11-10 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh converted_to_draft https://github.com/llvm/llvm-project/pull/165433 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-10 Thread Aleksandr Nogikh via cfe-commits
@@ -1839,6 +1839,39 @@ static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { RestrictAttr(S.Context, AL, DeallocE, DeallocPtrIdx)); } +static bool isSpanLikeType(const QualType &Ty) { + // Check that the type is a plain record with the fir

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-10 Thread Aleksandr Nogikh via cfe-commits
@@ -6642,7 +6642,8 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, CalleeDecl); } if (CalleeDecl->hasAttr() || -CalleeDecl->hasAttr()) { +CalleeDecl->hasAttr() || +CalleeDecl->hasAttr()) { --

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-10 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh updated https://github.com/llvm/llvm-project/pull/167010 >From 520daa237bdd014dd6f8f14f29d6b304d9440b4a Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 17 Oct 2025 18:05:36 +0200 Subject: [PATCH] [Clang] Introduce malloc_span attribute The "malloc" attrib

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-07 Thread Aleksandr Nogikh via cfe-commits
a-nogikh wrote: This PR is a reworked version of https://github.com/llvm/llvm-project/pull/165433. The original PR proposed the changes to the semantics of the `malloc` attribute itself, but the consensus was that adding a separate `malloc_attribute` would be a better approach. https://github

[clang] [Clang] Allow malloc for functions returning structs (PR #165433)

2025-11-07 Thread Aleksandr Nogikh via cfe-commits
a-nogikh wrote: A pull request with the `malloc_span` implementation: https://github.com/llvm/llvm-project/pull/167010 https://github.com/llvm/llvm-project/pull/165433 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-

[clang] [Clang] Introduce malloc_span attribute (PR #167010)

2025-11-07 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh created https://github.com/llvm/llvm-project/pull/167010 The "malloc" attribute restricts the possible function signatures to the ones returning a pointer, which is not the case for some non-standard allocation function variants. For example, P0901R11 proposed ::ope

[clang] [Clang] Introduce malloc_span attribute (PR #166937)

2025-11-07 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh closed https://github.com/llvm/llvm-project/pull/166937 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Introduce malloc_span attribute (PR #166937)

2025-11-07 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh created https://github.com/llvm/llvm-project/pull/166937 The "malloc" attribute restricts the possible function signatures to the ones returning a pointer, which is not the case for some non-standard allocation functions variants. For example, P0901R11 proposed ::oper

[clang] [Clang] Allow malloc for functions returning structs (PR #165433)

2025-11-06 Thread Aleksandr Nogikh via cfe-commits
a-nogikh wrote: Thank you for the feedback! * I've sent an email to [email protected]: https://gcc.gnu.org/pipermail/gcc/2025-November/246931.html * Dropped the `alloc_size`-related changes from the PR: after some more consideration, they didn't seem really necessary and only complicated the c

[clang] [Clang] Allow malloc for functions returning structs (PR #165433)

2025-11-06 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh edited https://github.com/llvm/llvm-project/pull/165433 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Allow malloc for functions returning structs (PR #165433)

2025-11-06 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh edited https://github.com/llvm/llvm-project/pull/165433 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Allow malloc and alloc_size attributes for functions returning structs (PR #165433)

2025-11-06 Thread Aleksandr Nogikh via cfe-commits
@@ -5753,3 +5753,23 @@ StringRef PredefinedSugarType::getName(Kind KD) { } llvm_unreachable("unexpected kind"); } + +bool Type::isSpanLikeType() const { a-nogikh wrote: Hmm, yes, indeed, there are pointer+int structs that are not span-like at all. I've mo

[clang] [Clang] Allow malloc and alloc_size attributes for functions returning structs (PR #165433)

2025-11-06 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh updated https://github.com/llvm/llvm-project/pull/165433 >From cb8dba47bb92b013e92b9a9fc6fc434e5f20ce92 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 17 Oct 2025 18:05:36 +0200 Subject: [PATCH 1/4] [Clang] Allow malloc and alloc_size attributes for func

[clang] [Clang] Allow malloc and alloc_size attributes for functions returning structs (PR #165433)

2025-10-28 Thread Aleksandr Nogikh via cfe-commits
https://github.com/a-nogikh created https://github.com/llvm/llvm-project/pull/165433 These attributes restrict the possible function signatures to the ones returning a pointer, which is not the case for some non-standard allocation functions variants. For example, P0901R11 proposed ::operator