Specifies that the function returns null or a pointer to at least a
certain number of allocated bytes. sizeArgIdx and numArgIdx specify
the 0-based index of the function arguments that should be used to calculate
the number of bytes returned:
The optimizer may assume that an @allocSize function has no other side
effects and that it is valid to eliminate calls to the function if the
allocated memory is not used. The optimizer will eliminate all code from
foo in this example:
@allocSize(0) void* myAlloc(size_t size);
void foo() {
auto p = myAlloc(100);
p[0] = 1;
}
Specifies that the function returns null or a pointer to at least a certain number of allocated bytes. sizeArgIdx and numArgIdx specify the 0-based index of the function arguments that should be used to calculate the number of bytes returned:
bytes = argsizeArgIdx * (numArgIdx < 0) ? argnumArgIdx : 1
The optimizer may assume that an @allocSize function has no other side effects and that it is valid to eliminate calls to the function if the allocated memory is not used. The optimizer will eliminate all code from foo in this example: @allocSize(0) void* myAlloc(size_t size); void foo() { auto p = myAlloc(100); p[0] = 1; }
See LLVM LangRef for more details: http://llvm.org/docs/LangRef.html#function-attributes
This attribute has no effect for LLVM < 3.9.