Index: include/clang/Basic/DiagnosticGroups.td =================================================================== --- include/clang/Basic/DiagnosticGroups.td +++ include/clang/Basic/DiagnosticGroups.td @@ -207,6 +207,7 @@ [NonModularIncludeInFrameworkModule]>; def IncompleteModule : DiagGroup<"incomplete-module", [IncompleteUmbrella, NonModularIncludeInModule]>; +def ModuleMapMissing : DiagGroup<"module-map-missing">; def InvalidNoreturn : DiagGroup<"invalid-noreturn">; def InvalidSourceEncoding : DiagGroup<"invalid-source-encoding">; Index: include/clang/Basic/DiagnosticLexKinds.td =================================================================== --- include/clang/Basic/DiagnosticLexKinds.td +++ include/clang/Basic/DiagnosticLexKinds.td @@ -611,6 +611,9 @@ def err_mmap_expected_attribute : Error<"expected an attribute name">; def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">, InGroup; +def warn_module_map_not_found : Warning< + "File '%0' specified via -fmodule-map-file not found">, + InGroup; def warn_auto_module_import : Warning< "treating #%select{include|import|include_next|__include_macros}0 as an " Index: lib/Lex/HeaderSearch.cpp =================================================================== --- lib/Lex/HeaderSearch.cpp +++ lib/Lex/HeaderSearch.cpp @@ -578,7 +578,9 @@ for (const auto &Filename : HSOpts->ModuleMapFiles) if (const FileEntry *File = FileMgr.getFile(Filename)) loadModuleMapFile(File, /*IsSystem=*/false); - HSOpts->ModuleMapFiles.clear(); + else + Diags.Report(diag::warn_module_map_not_found) << Filename; + HSOpts->ModuleMapFiles.clear(); } if (SuggestedModule) Index: test/Modules/pr21217.cpp =================================================================== --- test/Modules/pr21217.cpp +++ test/Modules/pr21217.cpp @@ -0,0 +1,6 @@ +// RUN: not %clang_cc1 -fmodules -fmodule-map-file=does-not-exist.modulemap -verify %s 2>&1 | \ +// RUN: FileCheck %s + +// CHECK: File 'does-not-exist.modulemap' specified via -fmodule-map-file not found + +#include "Inputs/private/common.h"