[cfe-commits] r42857 - in /cfe/trunk: AST/ASTContext.cpp AST/Builtins.cpp Sema/SemaDecl.cpp include/clang/AST/ASTContext.h include/clang/AST/Builtins.def

Chris Lattner clattner at apple.com
Thu Oct 18 15:18:03 PDT 2007


On Oct 12, 2007, at 3:04 AM, Gabor Greif wrote:

> Hi Chris,
>
> looks like the __builtin_va_alist is not a typedef,
> but a variable/stack slot.

Ah, I see.  This is very very strange.

I'm not sure what the right solution is.  Two options:

1. Implement native support for this in clang.
2. Use a 'fixincludes' style of approach to change the system header.

In either case, I'm not likely to have time to work on this in the  
near future, sorry! :(

-Chris

> It arises from expanding
>
> va_start on solaris.
>
> Here is the original function:
>
> void check_empty_format_string(char* buf)
> {
>   va_list ap;
>   va_start(ap,buf);
>   vprintf("",ap); // expected-warning {{format string is empty}}
>   sprintf(buf,""); // expected-warning {{format string is empty}}
> }
>
> And its expansion (clang -E):
>
> void check_empty_format_string(char* buf)
> {
>
>   va_list ap;
>   (void) (ap = (__va_list) &__builtin_va_alist);
>
>   vprintf("",ap);
>   sprintf(buf,"");
>
> }
>
>
> Here is the portion from /usr/include/iso/stdarg_iso.h
> relevant for SPARC:
>
>     55  /*
>     56   * Many compilation systems depend upon the use of special  
> functions
>     57   * built into the the compilation system to handle variable  
> argument
>     58   * lists and stack allocations.  The method to obtain this  
> in SunOS
>     59   * is to define the feature test macro  
> "__BUILTIN_VA_ARG_INCR" which
>     60   * enables the following special built-in functions:
>     61   *  __builtin_alloca
>     62   *  __builtin_va_alist
>     63   *  __builtin_va_arg_incr
>     64   * It is intended that the compilation system define this  
> feature test
>     65   * macro, not the user of the system.
>     66   *
>     67   * The tests on the processor type are to provide a  
> transitional period
>     68   * for existing compilation systems, and may be removed in  
> a future
>     69   * release.
>     70   */
>     71  #if (defined(__BUILTIN_VA_ARG_INCR) || defined(__sparc) || \
>     72    defined(__i386)) && !defined(__lint)
>     73
>     74  /*
>     75   * Instruction set architectures which use a simple pointer  
> to the
>     76   * argument save area share a common implementation.
>     77   */
>     78  #define va_start(list, name)  (void) (list = (__va_list)  
> &__builtin_va_alist)
>     79  #define va_arg(list, mode)  ((mode *)__builtin_va_arg_incr 
> ((mode *)list))[0]
>     80
>     81  #elif defined(__ia64)
>
>
> I hope this info is sufficient to get started :-)
>
> Cheers,
>
> 	Gabor
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list