[cfe-dev] Tiny patch for va_list definition on x86-64 target

Abramo Bagnara abramobagnara at tin.it
Thu Jul 2 09:22:27 PDT 2009


Here attached you find a patch that add and intermediate typedef between
struct __va_list_tag and __builtin_va_list on x86-64.

This patch is fundamental in our project to recompile with gcc a pretty
printed output of clang AST.

The fact is that until __builtin_va_list is an array of struct
__va_list_tag, it decays to struct __va_list_tag * that is a type that
it's impossibile to match with gcc internal type.

With this patch, instead, va_list decays to __va_list_tag_t* that is
easily mappable to gcc internal type for va_list.

To make it match it's only needed to do the following:

/*
typedef struct __va_list_tag {
  unsigned int gp_offset;
  unsigned int fp_offset;
  void *overflow_arg_area;
  void *reg_save_area;
} __va_list_tag_t;
typedef __va_list_tag_t __builtin_va_list[1];
*/
extern __builtin_va_list __va_list_object;
typedef typeof(__va_list_object[0]) __va_list_tag_t;

i.e., we remove the two declarations added by clang and we substitute
them with other two that permit the pretty printed clang AST to be
compiled without other modifications.

For all the other uses of va_list the proposed patch is harmless (the
type of __builtin_va_list remains the same).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: va_list.patch
Type: text/x-patch
Size: 488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090702/9390696a/attachment.bin>


More information about the cfe-dev mailing list