diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fd9e686485552..b7ad432738b29 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1709,6 +1709,13 @@ def EmptyBases : InheritableAttr, TargetSpecificAttr { def AllocSize : InheritableAttr { let Spellings = [GCC<"alloc_size">]; let Subjects = SubjectList<[HasFunctionProto]>; + // The parameter names here are a bit misleading. + // When used with a single argument, the first argument is obviously the + // allocation size; but when used with two arguments, the first argument is + // usually the number of elements, while the second argument is usually the + // element size - the reverse of how they are named here. + // The documentation of both GCC and clang does not describe any semantic + // difference between the first and second argument. let Args = [ParamIdxArgument<"ElemSizeParam">, ParamIdxArgument<"NumElemsParam", /*opt*/ 1>]; let TemplateDependent = 1;