This is an archive of the discontinued LLVM Phabricator instance.

Support for GCC's `__builtin_va_arg_pack{,_len}`
AbandonedPublic

Authored by erik.pilkington on Feb 1 2019, 7:31 PM.

Details

Summary

You can read more about these attributes here: https://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Constructing-Calls.html

These are needed to support C++-compatible _FORTIFY_SOURCE wrappers for libc function (these can't be done with macros). For instance, without these attributes, there isn't any way to write the following:

extern inline __attribute__((gnu_inline))
int sprintf(char *str, const char *fmt, ...) {
    return __builtin___sprintf_chk(str, 0, __builtin_object_size(str, 0), fmt, __builtin_va_arg_pack());
}

Fixes llvm.org/PR7219 & rdar://11102669

Thanks for taking a look!
Erik

Diff Detail

Event Timeline

erik.pilkington created this revision.Feb 1 2019, 7:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2019, 7:31 PM
erik.pilkington abandoned this revision.Feb 3 2019, 11:26 AM

Tentatively marking as abandoned, Eli suggested a different approach in the LLVM review which I'm going to look into.