From 64bb60a471a5ddc9c9bec413c65fdab730a1e4b0 Mon Sep 17 00:00:00 2001 From: Volodymyr Sapsai Date: Thu, 8 May 2025 09:07:33 -0700 Subject: [Modules] Don't fail when an unused textual header is missing. (#138227) According to the documentation > A header declaration that does not contain `exclude` nor `textual` specifies a header that contributes to the enclosing module. Which means that `exclude` and `textual` header don't contribute to the enclosing module and their presence isn't required to build such a module. The keywords tell clang how a header should be treated in a context of the module but they don't add headers to the module. When a textual header *is* used, clang still emits "file not found" error pointing to the location where the missing file is included. --- clang/lib/Lex/ModuleMap.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'clang/lib/Lex/ModuleMap.cpp') diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 81a74d5..d073237 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -310,8 +310,10 @@ void ModuleMap::resolveHeader(Module *Mod, } else if (Header.HasBuiltinHeader && !Header.Size && !Header.ModTime) { // There's a builtin header but no corresponding on-disk header. Assume // this was supposed to modularize the builtin header alone. - } else if (Header.Kind == Module::HK_Excluded) { - // Ignore missing excluded header files. They're optional anyway. + } else if ((Header.Kind == Module::HK_Excluded) || + (Header.Kind == Module::HK_Textual)) { + // Ignore excluded and textual header files as a module can be built with + // such headers missing. } else { // If we find a module that has a missing header, we mark this module as // unavailable and store the header directive for displaying diagnostics. -- cgit v1.1