[PATCH] D159064: [Modules] Make clang modules for the C standard library headers

Ian Anderson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 8 15:17:00 PDT 2023


iana added inline comments.


================
Comment at: clang/test/Modules/Inputs/System/usr/include/stdint.h:2
 typedef int my_awesome_nonstandard_integer_type;
+
+/* C99 7.18.1.1 Exact-width integer types.
----------------
dexonsmith wrote:
> benlangmuir wrote:
> > iana wrote:
> > > iana wrote:
> > > > benlangmuir wrote:
> > > > > Why do we need all this code now (I assume this is copied from the real header)?
> > > > It's to support the tests I added to Modules/compiler_builtins.m. stdatomic.h and inttypes.h rely on stdint.h contents from the C library, and on complex.h and inttypes.h and math.h being present. I could just test the modules with `-ffreestanding` I think, would that be better?
> > > (and yes I just copied it from the builtin header)
> > I'm not sure what the best approach is here, but this seems heavy for a test.  Do we expect to need to keep this up to date? If so maybe ffreestanding for the specific test cases this affects would be a better tradeoff.  Maybe someone else has a suggestion here
> This reflects *most* of the content in `stdint.h`.
> 
> One idea would be to copy the full header over during the test setup and fix it up, either:
> - strip out the header/footer or
> - `sed -e "s/__STDC_HOSTED__/0/g"`
> so that it always provides content (even when not freestanding).
IMO it doesn't need to be that sophisticated, the types just have to exist for stdtomic.h to compile. I could chop all the comments and define everything to `int` and I think that'd be fine too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159064/new/

https://reviews.llvm.org/D159064



More information about the cfe-commits mailing list