Clang Project

clang_source_code/test/Analysis/Inputs/system-header-simulator-for-valist.h
1// Like the compiler, the static analyzer treats some functions differently if
2// they come from a system header -- for example, it is assumed that system
3// functions do not arbitrarily free() their parameters, and that some bugs
4// found in system headers cannot be fixed by the user and should be
5// suppressed.
6
7#pragma clang system_header
8
9#ifdef __cplusplus
10#define restrict /*restrict*/
11#endif
12
13typedef __builtin_va_list va_list;
14
15#define va_start(ap, param) __builtin_va_start(ap, param)
16#define va_end(ap)          __builtin_va_end(ap)
17#define va_arg(ap, type)    __builtin_va_arg(ap, type)
18#define va_copy(dst, src)   __builtin_va_copy(dst, src)
19
20int vprintf (const char *restrict format, va_list arg);
21
22int vsprintf (char *restrict s, const char *restrict format, va_list arg);
23
24int some_library_function(int n, va_list arg);
25
26// No warning from system header.
27inline void __impl_detail(int fst, ...) {
28  va_list va;
29  (void)va_arg(va, int);
30}
31