[PATCH] D57634: Support for GCC's `__builtin_va_arg_pack{,_len}`

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 1 19:31:17 PST 2019


erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, jfb, aaron.ballman.
Herald added subscribers: kristina, dexonsmith, jkorous.
Herald added a project: clang.

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


Repository:
  rC Clang

https://reviews.llvm.org/D57634

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/builtin-va-arg-pack.c
  clang/test/Sema/builtin-va-arg-pack.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57634.184884.patch
Type: text/x-patch
Size: 20256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190202/2e9843e3/attachment-0001.bin>


More information about the cfe-commits mailing list