9 Commits

Author SHA1 Message Date
Roland McGrath
86f0e6dc11
[libc] Add --json mode for hdrgen (#127847)
This adds a feature to hdrgen to emit JSON summaries of header
files for build system integration.  For now the summaries have
only the basic information about each header that is relevant for
build and testing purposes: the standards and includes lists.
2025-02-19 16:07:45 -08:00
Roland McGrath
2157aecfe4
[libc] Produce standard-compliant header guard macros in hdrgen (#127356)
Macros starting with alphabetic characters such as "LLVM" are in
the application name space and cannot be defined or used by a
conforming implementation's headers.  This fixes the headers that
are entirely generated, and the __llvm-libc-common.h header to
use a conforming macro name for the header guard.  That is, it
starts with "_LLVM_LIBC_" instead of "LLVM_LIBC_", as identifiers
starting with an underscore followed by a capital letter are in
the name space reserved for the implementation.

The remaining headers either will be fixed implicitly by removal
of their custom template files, or will need to be fixed by hand.
2025-02-15 17:36:44 -08:00
Roland McGrath
68a82a2298
[libc] Elide extra space in hdrgen function declarations (#127287)
When the return type's rendering already doesn't end with an
identifier character, such as when it's `T *`, then idiomatic
syntax does not include a space before the `(` and arguments.
2025-02-14 17:09:58 -08:00
Roland McGrath
303f241544
[libc] Make template_header optional for hdrgen (#127259)
This allows a YAML file to omit `template_header` and have no
`.h.def` file.  A default template is generated based purely on
the information in the YAML file.  This should handle most of the
cases.  For now, it's exercised (aside from the hdrgen tests)
only for one of the simplest cases: <ctype.h>.

This includes making the parser notice the "standards" YAML field
at the top (header) level, not just in "functions" lists.  The
standards listed for the header overall and for the individual
functions both feed into how a fully-generated header describes
itself in comments.  To go with this, files using the default
generated template must stick to a new uniform set of spellings
for the "standards" lists.  As more custom template files are
retired, the corresponding YAML files will need all their
standards lists normalized.  For now, ctype.yaml is updated
with correct attribution for the POSIX `_l` extensions.
2025-02-14 14:01:18 -08:00
Roland McGrath
aa500a79fc
[libc] Make hdrgen deduce header type lists from function signatures (#127251)
With this, the `types` list in YAML files should only be used to
list the types that a standard specifies should be in that header
per se.  All the types referenced in function signatures will be
collected automatically.
2025-02-14 12:54:46 -08:00
Roland McGrath
d2dd8021fd
[libc] Make hdrgen emit correct relative paths for llvm-libc-types (#127150)
This makes hdrgen emit `#include "..."` lines using the correct
relative path (number of `../` steps, if any) for the containing
header, and includes this in the sorted block of `#include` lines
also used for the macro headers.
2025-02-14 11:01:26 -08:00
Roland McGrath
6d3bfddb9d
[libc] Make hdrgen support macro_header YAML field. (#123265)
A macro can specify macro_header instead of macro_value to
indicate that an llvm-libc-macros/ header file is supposed to
define this macro.  This is used for dlfcn.h, which previously
bogusly redefined the RTLD_* macros to empty.
2025-02-13 16:07:06 -08:00
Roland McGrath
906cbbbd3c
[libc] Fix hdrgen output for no-argument functions (#123245)
The hdrgen output is C, not C++.
2025-01-16 19:20:53 -08:00
Roland McGrath
9abcca5e25
[libc] Move hdrgen into utils/ subdirectory (#121256) 2024-12-30 15:36:53 -08:00