[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
Mon Aug 28 23:27:03 PDT 2023


iana added inline comments.


================
Comment at: clang/lib/Headers/__stddef_null.h:14
+ * __need_NULL and rely on stddef.h to redefine NULL to the correct value again.
+ * Modules don't support redefining macros like that, but support that pattern
+ * in the non-modules case.
----------------
I couldn't come up with anything clever to support this in modules. If I get rid of the guard, `NULL` still doesn't get redefined in modules. If I move the `undef` to stddef.h then `NULL` gets undefined, but not redefined. So I think precompiled modules must inherently have `#pragma once` semantics. If we really had to, we could move this back into stddef.h and let it be textual, but it's distasteful that `NULL` gets defined in every single module that includes stddef.h and has to be merged later.


================
Comment at: clang/test/Headers/stdarg.c:4
 // RUN: %clang_cc1 -fsyntax-only -verify=c99 -Werror=implicit-function-declaration -std=c99 %t/stdarg0.c
+// RUN: %clang_cc1 -fsyntax-only -verify=c89-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=implicit-function-declaration -std=c89 %t/stdarg0.c
+// RUN: %clang_cc1 -fsyntax-only -verify=c99-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=implicit-function-declaration -std=c99 %t/stdarg0.c
----------------
I think it's fine to use these same tests to validate that modules mode makes the same things visible as non-modules mode depending on the standard and set `__need_` macros?


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