Index: include/clang/Basic/DiagnosticFrontendKinds.td =================================================================== --- include/clang/Basic/DiagnosticFrontendKinds.td +++ include/clang/Basic/DiagnosticFrontendKinds.td @@ -179,6 +179,10 @@ "compilation">, InGroup>, DefaultError; def err_module_map_not_found : Error<"module map file '%0' not found">, DefaultFatal; +def err_module_map_wrong_perms : Error<"insufficient privileges to read file '%0'">, + DefaultFatal; +def err_module_map_missing_stat : Error<"cannot retrieve status infos for file '%0'">, + DefaultFatal; def err_missing_module_name : Error< "no module name provided; specify one with -fmodule-name=">, DefaultFatal; Index: lib/Frontend/FrontendActions.cpp =================================================================== --- lib/Frontend/FrontendActions.cpp +++ lib/Frontend/FrontendActions.cpp @@ -272,7 +272,23 @@ << Filename; return false; } - + + // Emit a diagnostic if we can't read the module map. + vfs::Status Result; + bool S = CI.getFileManager().getNoncachedStatValue(Filename, Result); + if (!S) { + llvm::sys::fs::perms P = Result.getPermissions(); + if (!(P & llvm::sys::fs::perms::all_read)) { + CI.getDiagnostics().Report(diag::err_module_map_wrong_perms) + << Filename; + return false; + } + } else { + CI.getDiagnostics().Report(diag::err_module_map_missing_stat) + << Filename; + return false; + } + // Set up embedding for any specified files. Do this before we load any // source files, including the primary module map for the compilation. for (const auto &F : CI.getFrontendOpts().ModulesEmbedFiles) {