This was a fun patch :)
This patch adds the parameter attribute pass_object_size to Clang. The design doc for this attribute is available here: https://docs.google.com/document/d/14TwNLxFL_jhiYn7_kppNUDiaTopRAIY5bc-B8NcnKMM/edit?usp=sharing
General notes:
- Never mangled things before, so I'm open to any suggestions on how to make the mangling for pass_object_size better :)
- There's a tiny diagnostics bugfix in here -- I'm happy to make that its own patch. (See: tryGetFunctionProtoType in SemaOverload.cpp)
- A lot of the additions to Sema (anything that's a boolean named like TakingCandidateAddress) are to improve diagnostics on templated functions with pass_object_size on their parameters. I'm happy to simplify the diff a bit if we think that the improved diag ("functions with pass_object_size params cannot have their address taken" vs "assigning to 'int (*)(void *)' from incompatible type 'int (void *const pass_object_size)'") isn't worth the extra cruft.
@rsmith: Other than the name change, the design has changed (since the last time we talked) such that having pass_object_size(N) on some parameter P makes the function act like there's an enable_if that disables the function if we can't determine the object size of P at the callsite. More concretely:
- One can no longer take the address of a function with pass_object_size
- If an overload candidate parameter with pass_object_size on it cannot have its object size determined, then the candidate is not viable.
- If there's no overloading going on at all (e.g. in C), it's still an error to call a function with pass_object_size on one or more of its params if the object size of that param can't be determined.