aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderSearch.cpp
diff options
context:
space:
mode:
authorMichael Spencer <bigcheesegs@gmail.com>2023-12-14 14:03:57 -0800
committerGitHub <noreply@github.com>2023-12-14 14:03:57 -0800
commita171d248ca34b8b6f8de11d42a83ad981285963a (patch)
tree1a7d71e80ffe92f37e18cf7653dea4c8d20b3a48 /clang/lib/Lex/HeaderSearch.cpp
parentf956bfe169c7debd72acd22b124e5ae78174b3a0 (diff)
downloadllvm-a171d248ca34b8b6f8de11d42a83ad981285963a.zip
llvm-a171d248ca34b8b6f8de11d42a83ad981285963a.tar.gz
llvm-a171d248ca34b8b6f8de11d42a83ad981285963a.tar.bz2
[clang][modules] Deprecate module.map in favor of module.modulemap (#75142)
This patch deprecates `module.map` in favor of `module.modulemap`, which has been the preferred form since 2014. The eventual goal is to remove support for `module.map` to reduce the number of stats Clang needs to do while searching for module map files. This patch touches a lot of files, but the majority of them are just renaming tests or references to the file in comments or documentation. The relevant files are: * lib/Lex/HeaderSearch.cpp * include/clang/Basic/DiagnosticGroups.td * include/clang/Basic/DiagnosticLexKinds.td
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index f24013d..a0ac0ea 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1656,7 +1656,8 @@ bool HeaderSearch::findUsableModuleForFrameworkHeader(
}
static OptionalFileEntryRef getPrivateModuleMap(FileEntryRef File,
- FileManager &FileMgr) {
+ FileManager &FileMgr,
+ DiagnosticsEngine &Diags) {
StringRef Filename = llvm::sys::path::filename(File.getName());
SmallString<128> PrivateFilename(File.getDir().getName());
if (Filename == "module.map")
@@ -1665,7 +1666,14 @@ static OptionalFileEntryRef getPrivateModuleMap(FileEntryRef File,
llvm::sys::path::append(PrivateFilename, "module.private.modulemap");
else
return std::nullopt;
- return FileMgr.getOptionalFileRef(PrivateFilename);
+ auto PMMFile = FileMgr.getOptionalFileRef(PrivateFilename);
+ if (PMMFile) {
+ if (Filename == "module.map")
+ Diags.Report(diag::warn_deprecated_module_dot_map)
+ << PrivateFilename << 1
+ << File.getDir().getName().endswith(".framework");
+ }
+ return PMMFile;
}
bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
@@ -1731,7 +1739,8 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
}
// Try to load a corresponding private module map.
- if (OptionalFileEntryRef PMMFile = getPrivateModuleMap(File, FileMgr)) {
+ if (OptionalFileEntryRef PMMFile =
+ getPrivateModuleMap(File, FileMgr, Diags)) {
if (ModMap.parseModuleMapFile(*PMMFile, IsSystem, Dir)) {
LoadedModuleMaps[File] = false;
return LMM_InvalidModuleMap;
@@ -1755,11 +1764,14 @@ HeaderSearch::lookupModuleMapFile(DirectoryEntryRef Dir, bool IsFramework) {
if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
return *F;
- // Continue to allow module.map
+ // Continue to allow module.map, but warn it's deprecated.
ModuleMapFileName = Dir.getName();
llvm::sys::path::append(ModuleMapFileName, "module.map");
- if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
+ if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName)) {
+ Diags.Report(diag::warn_deprecated_module_dot_map)
+ << ModuleMapFileName << 0 << IsFramework;
return *F;
+ }
// For frameworks, allow to have a private module map with a preferred
// spelling when a public module map is absent.