[clang] [Clang] Introduce malloc_span attribute (PR #167010)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 18 05:48:36 PST 2025
================
@@ -3449,6 +3449,24 @@ def err_attribute_integers_only : Error<
def warn_attribute_return_pointers_only : Warning<
"%0 attribute only applies to return values that are pointers">,
InGroup<IgnoredAttributes>;
+def warn_attribute_return_span_only
+ : Warning<"%0 attribute only applies to functions that return span-like "
+ "structures">,
+ InGroup<IgnoredAttributes>;
+def note_returned_not_struct : Note<"returned type is not a struct/class type">;
+def note_returned_incomplete_type : Note<"returned type is incomplete">;
+def note_returned_not_two_field_struct
+ : Note<"returned struct/class has %0 fields, expected 2">;
+def note_returned_not_span_struct
+ : Note<"returned struct/class fields are not a supported combination for a "
+ "span-like type (expected pointer/integer or pointer/pointer)">;
+def note_returned_not_integer_field
+ : Note<"field #%0 expected to be an integer">;
+def note_returned_not_wide_enough_field
+ : Note<"integer field #%0 of span-like type is not wide enough (minimum "
+ "width: %1)">;
+def note_inherits_not_empty_base
+ : Note<"returned struct/class inherits from a non-empty base">;
----------------
AaronBallman wrote:
This one could use `class` instead of `struct` because inheritance is a C++ thing, or we could look at which tag is used in practice and print that with `%select`.
https://github.com/llvm/llvm-project/pull/167010
More information about the cfe-commits
mailing list