[FunctionAttrs] Move the malloc-like test to a static helper function