Index: include/module.modulemap =================================================================== --- include/module.modulemap +++ include/module.modulemap @@ -42,8 +42,15 @@ // provided by compiler. // provided by compiler. module stddef_h { - // 's __need_* macros require textual inclusion. - textual header "stddef.h" + // NOTE: should technically be a textual header due to the + // __need_* macros. However Clang transforms this module definition into: + // module stddef_h { + // textual header "clang/builtin-includes/stddef.h" + // header "libcxx/include/stddef.h" + // } + // Therefore Clang's stddef.h resolves the __need_* macros before + // building libc++'s header as a non-textual module. + header "stddef.h" } module stdint_h { header "stdint.h" Index: test/libcxx/modules/cstddef_h_exports.sh.cpp =================================================================== --- /dev/null +++ test/libcxx/modules/cstddef_h_exports.sh.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: modules-support + +// Test that stddef.h provides size_t + +// RUN: %build_module + +#include + +int main() { + size_t x; ((void)x); + std::size_t y; ((void)y); +} Index: test/libcxx/modules/stddef_h_exports.sh.cpp =================================================================== --- /dev/null +++ test/libcxx/modules/stddef_h_exports.sh.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: modules-support, verify-support + +// Test that stddef.h provides size_t + +// RUN: %compile_module %verify + +#include + +int main() { + size_t x; // expected-error {{missing '#include '}} +} Index: test/libcxx/modules/stdlib_h_exports.sh.cpp =================================================================== --- /dev/null +++ test/libcxx/modules/stdlib_h_exports.sh.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: modules-support, verify-support + +// Test that stddef.h provides size_t + +// RUN: %build_module + +#include + +int main() { + size_t x; +}