-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][modules] Deprecate module.map in favor of module.modulemap #75142
Conversation
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
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clangd Author: Michael Spencer (Bigcheese) ChangesThis patch deprecates 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:
Patch is 108.34 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/75142.diff 142 Files Affected:
diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index f12441061c1983..9cdc57ec01f327 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1917,14 +1917,14 @@ TEST_F(SymbolCollectorTest, UndefOfModuleMacro) {
#undef X
)cpp";
TU.AdditionalFiles["foo.h"] = "#define X 1";
- TU.AdditionalFiles["module.map"] = R"cpp(
+ TU.AdditionalFiles["module.modulemap"] = R"cpp(
module foo {
header "foo.h"
export *
}
)cpp";
TU.ExtraArgs.push_back("-fmodules");
- TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("module.map"));
+ TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("module.modulemap"));
TU.OverlayRealFileSystemForModules = true;
TU.build();
diff --git a/clang-tools-extra/docs/modularize.rst b/clang-tools-extra/docs/modularize.rst
index 9dde467ec30847..64ca8c99d4e8ef 100644
--- a/clang-tools-extra/docs/modularize.rst
+++ b/clang-tools-extra/docs/modularize.rst
@@ -20,7 +20,7 @@ map.
:program:`modularize` also has an assistant mode option for generating
a module map file based on the provided header list. The generated file
is a functional module map that can be used as a starting point for a
-module.map file.
+module.modulemap file.
Getting Started
===============
diff --git a/clang-tools-extra/include-cleaner/test/Inputs/modules/module.map b/clang-tools-extra/include-cleaner/test/Inputs/modules/module.modulemap
similarity index 100%
rename from clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
rename to clang-tools-extra/include-cleaner/test/Inputs/modules/module.modulemap
diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp
index daa9c048279e03..f3e7dfc20b027d 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -51,20 +51,20 @@
// to the header list file directory. Use -prefix to specify a
// different directory.
// -module-map-path=(module map)
-// Skip the checks, and instead act as a module.map generation
+// Skip the checks, and instead act as a module.modulemap generation
// assistant, generating a module map file based on the header list.
// An optional "-root-module=(rootName)" argument can specify a root
-// module to be created in the generated module.map file. Note that
-// you will likely need to edit this file to suit the needs of your
-// headers.
+// module to be created in the generated module.modulemap file. Note
+// that you will likely need to edit this file to suit the needs of
+// your headers.
// -problem-files-list=(problem files list file name)
// For use only with module map assistant. Input list of files that
// have problems with respect to modules. These will still be
// included in the generated module map, but will be marked as
// "excluded" headers.
// -root-module=(root module name)
-// Specifies a root module to be created in the generated module.map
-// file.
+// Specifies a root module to be created in the generated
+// module.modulemap file.
// -block-check-header-list-only
// Only warn if #include directives are inside extern or namespace
// blocks if the included header is in the header list.
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 089f52f52ec4d3..e65f711249e3f5 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -103,10 +103,10 @@ std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies() {
// Do coverage checks.
// For each loaded module map, do header coverage check.
-// Starting from the directory of the module.map file,
+// Starting from the directory of the module.modulemap file,
// Find all header files, optionally looking only at files
// covered by the include path options, and compare against
-// the headers referenced by the module.map file.
+// the headers referenced by the module.modulemap file.
// Display warnings for unaccounted-for header files.
// Returns 0 if there were no errors or warnings, 1 if there
// were warnings, 2 if any other problem, such as a bad
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.h b/clang-tools-extra/modularize/ModularizeUtilities.h
index 6da15e42f1f1ea..64675022dad76e 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.h
+++ b/clang-tools-extra/modularize/ModularizeUtilities.h
@@ -89,10 +89,10 @@ class ModularizeUtilities {
/// Do coverage checks.
/// For each loaded module map, do header coverage check.
- /// Starting from the directory of the module.map file,
+ /// Starting from the directory of the module.modulemap file,
/// Find all header files, optionally looking only at files
/// covered by the include path options, and compare against
- /// the headers referenced by the module.map file.
+ /// the headers referenced by the module.modulemap file.
/// Display warnings for unaccounted-for header files.
/// \param IncludePaths The include paths to check for files.
/// (Note that other directories above these paths are ignored.
diff --git a/clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap b/clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
index fbb8e7db4d10c2..64180adf5beb35 100644
--- a/clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
+++ b/clang-tools-extra/test/modularize/Inputs/CompileError/module.modulemap
@@ -1,4 +1,4 @@
-// module.map
+// module.modulemap
module Level1A {
header "Level1A.h"
diff --git a/clang-tools-extra/test/modularize/Inputs/CoverageNoProblems/module.modulemap b/clang-tools-extra/test/modularize/Inputs/CoverageNoProblems/module.modulemap
index d2b0957b76e1ca..39af7d5dcf366e 100644
--- a/clang-tools-extra/test/modularize/Inputs/CoverageNoProblems/module.modulemap
+++ b/clang-tools-extra/test/modularize/Inputs/CoverageNoProblems/module.modulemap
@@ -1,4 +1,4 @@
-// module.map
+// module.modulemap
module Level1A {
header "Includes1/Level1A.h"
diff --git a/clang-tools-extra/test/modularize/Inputs/CoverageProblems/module.modulemap b/clang-tools-extra/test/modularize/Inputs/CoverageProblems/module.modulemap
index dbe0bb8507cf0b..2b8b23054a0195 100644
--- a/clang-tools-extra/test/modularize/Inputs/CoverageProblems/module.modulemap
+++ b/clang-tools-extra/test/modularize/Inputs/CoverageProblems/module.modulemap
@@ -1,4 +1,4 @@
-// module.map
+// module.modulemap
module Level1A {
header "Level1A.h"
diff --git a/clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap b/clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
index daa06fca78d26b..9acb4923f9ac37 100644
--- a/clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
+++ b/clang-tools-extra/test/modularize/Inputs/MissingHeader/module.modulemap
@@ -1,4 +1,4 @@
-// module.map
+// module.modulemap
module Level1A {
header "Level1A.h"
diff --git a/clang-tools-extra/test/pp-trace/Inputs/module.map b/clang-tools-extra/test/pp-trace/Inputs/module.modulemap
similarity index 84%
rename from clang-tools-extra/test/pp-trace/Inputs/module.map
rename to clang-tools-extra/test/pp-trace/Inputs/module.modulemap
index 31f33c5bb14902..f16bbc6e2e05b4 100644
--- a/clang-tools-extra/test/pp-trace/Inputs/module.map
+++ b/clang-tools-extra/test/pp-trace/Inputs/module.modulemap
@@ -1,4 +1,4 @@
-// module.map
+// module.modulemap
module Level1A {
header "Level1A.h"
diff --git a/clang/include/clang-c/BuildSystem.h b/clang/include/clang-c/BuildSystem.h
index 296e61247cef57..57e16af20a7006 100644
--- a/clang/include/clang-c/BuildSystem.h
+++ b/clang/include/clang-c/BuildSystem.h
@@ -95,7 +95,7 @@ CINDEX_LINKAGE void clang_free(void *buffer);
CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay);
/**
- * Object encapsulating information about a module.map file.
+ * Object encapsulating information about a module.modulemap file.
*/
typedef struct CXModuleMapDescriptorImpl *CXModuleMapDescriptor;
@@ -109,7 +109,7 @@ CINDEX_LINKAGE CXModuleMapDescriptor
clang_ModuleMapDescriptor_create(unsigned options);
/**
- * Sets the framework module name that the module.map describes.
+ * Sets the framework module name that the module.modulemap describes.
* \returns 0 for success, non-zero to indicate an error.
*/
CINDEX_LINKAGE enum CXErrorCode
@@ -117,7 +117,7 @@ clang_ModuleMapDescriptor_setFrameworkModuleName(CXModuleMapDescriptor,
const char *name);
/**
- * Sets the umbrella header name that the module.map describes.
+ * Sets the umbrella header name that the module.modulemap describes.
* \returns 0 for success, non-zero to indicate an error.
*/
CINDEX_LINKAGE enum CXErrorCode
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index caee2dc6daadb6..80b5680b94f6ca 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -40,6 +40,7 @@ def : DiagGroup<"auto-import">;
def FrameworkHdrQuotedInclude : DiagGroup<"quoted-include-in-framework-header">;
def FrameworkIncludePrivateFromPublic :
DiagGroup<"framework-include-private-from-public">;
+def DeprecatedModuleDotMap : DiagGroup<"deprecated-module-dot-map">;
def FrameworkHdrAtImport : DiagGroup<"atimport-in-framework-header">;
def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
def CXXPre14CompatBinaryLiteral : DiagGroup<"c++98-c++11-compat-binary-literal">;
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 564ca48cc32ac5..75ca2fa16d3485 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -884,6 +884,9 @@ def warn_quoted_include_in_framework_header : Warning<
def warn_framework_include_private_from_public : Warning<
"public framework header includes private framework header '%0'"
>, InGroup<FrameworkIncludePrivateFromPublic>;
+def warn_deprecated_module_dot_map : Warning<
+ "'%0' as a module map name is deprecated, rename it to %select{module.modulemap|module.private.modulemap}1%select{| in the 'Modules' directory of the framework}2">,
+ InGroup<DeprecatedModuleDotMap>;
def remark_pp_include_directive_modular_translation : Remark<
"treating #%select{include|import|include_next|__include_macros}0 as an "
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index c03cf19688d961..bf619bb1bb8300 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.
diff --git a/clang/test/ARCMT/Inputs/module.map b/clang/test/ARCMT/Inputs/module.modulemap
similarity index 100%
rename from clang/test/ARCMT/Inputs/module.map
rename to clang/test/ARCMT/Inputs/module.modulemap
diff --git a/clang/test/Index/Inputs/Frameworks/module.map b/clang/test/Index/Inputs/Frameworks/module.modulemap
similarity index 100%
rename from clang/test/Index/Inputs/Frameworks/module.map
rename to clang/test/Index/Inputs/Frameworks/module.modulemap
diff --git a/clang/test/Index/Inputs/Headers/module.map b/clang/test/Index/Inputs/Headers/module.modulemap
similarity index 100%
rename from clang/test/Index/Inputs/Headers/module.map
rename to clang/test/Index/Inputs/Headers/module.modulemap
diff --git a/clang/test/Index/Inputs/Headers/nested/module.map b/clang/test/Index/Inputs/Headers/nested/module.modulemap
similarity index 100%
rename from clang/test/Index/Inputs/Headers/nested/module.map
rename to clang/test/Index/Inputs/Headers/nested/module.modulemap
diff --git a/clang/test/Index/Inputs/module.map b/clang/test/Index/Inputs/module.modulemap
similarity index 100%
rename from clang/test/Index/Inputs/module.map
rename to clang/test/Index/Inputs/module.modulemap
diff --git a/clang/test/Index/Inputs/vfsoverlay.yaml b/clang/test/Index/Inputs/vfsoverlay.yaml
index 95b00bef7d0e4c..3e9718b4c4314f 100644
--- a/clang/test/Index/Inputs/vfsoverlay.yaml
+++ b/clang/test/Index/Inputs/vfsoverlay.yaml
@@ -3,8 +3,8 @@
'roots': [
{ 'name': 'OUT_DIR', 'type': 'directory',
'contents': [
- { 'name': 'module.map', 'type': 'file',
- 'external-contents': 'INPUT_DIR/module.map'
+ { 'name': 'module.modulemap', 'type': 'file',
+ 'external-contents': 'INPUT_DIR/module.modulemap'
},
{ 'name': 'ModuleNeedsVFS.h', 'type': 'file',
'external-contents': 'INPUT_DIR/module_needs_vfs.h'
diff --git a/clang/test/Modules/Inputs/Conflicts/module.map b/clang/test/Modules/Inputs/Conflicts/module.modulemap
similarity index 100%
rename from clang/test/Modules/Inputs/Conflicts/module.map
rename to clang/test/Modules/Inputs/Conflicts/module.modulemap
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/module.map b/clang/test/Modules/Inputs/DependsOnModule.framework/Modules/module.modulemap
similarity index 100%
rename from clang/test/Modules/Inputs/DependsOnModule.framework/module.map
rename to clang/test/Modules/Inputs/DependsOnModule.framework/Modules/module.modulemap
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map b/clang/test/Modules/Inputs/DependsOnModule.framework/Modules/module.private.modulemap
similarity index 100%
rename from clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map
rename to clang/test/Modules/Inputs/DependsOnModule.framework/Modules/module.private.modulemap
diff --git a/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map b/clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Modules/module.modulemap
similarity index 100%
rename from clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map
rename to clang/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Modules/module.modulemap
diff --git a/clang/test/Modules/Inputs/Modified/module.map b/clang/test/Modules/Inputs/Modified/module.modulemap
similarity index 100%
rename from clang/test/Modules/Inputs/Modified/module.map
rename to clang/test/Modules/Inputs/Modified/module.modulemap
diff --git a/clang/test/Modules/Inputs/ModuleDiags/module.map b/clang/test/Modules/Inputs/ModuleDiags/module.modulemap
similarity index 100%
rename from clang/test/Modules/Inputs/ModuleDiags/module.map
rename to clang/test/Modules/Inputs/ModuleDiags/module.modulemap
diff --git a/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/a.h b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/a.h
new file mode 100644
index 00000000000000..d571c6e4f799f3
--- /dev/null
+++ b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/a.h
@@ -0,0 +1 @@
+void will_be_found1(void);
diff --git a/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/module.map b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/module.map
new file mode 100644
index 00000000000000..ef46443cedc925
--- /dev/null
+++ b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/module.map
@@ -0,0 +1,3 @@
+module module_map {
+ header "a.h"
+}
diff --git a/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/module_private.map b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/module_private.map
new file mode 100644
index 00000000000000..d542172a1235e7
--- /dev/null
+++ b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/module_private.map
@@ -0,0 +1,3 @@
+module module_map.Private {
+ header "private.h"
+}
diff --git a/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/private.h b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map/private.h
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/Headers/a.h b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/Headers/a.h
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/PrivateHeaders/private.h b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/PrivateHeaders/private.h
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/module.map b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/module.map
new file mode 100644
index 00000000000000..f30545f8a88cdd
--- /dev/null
+++ b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/module.map
@@ -0,0 +1,3 @@
+framework module Module_Map_F {
+ header "a.h"
+}
diff --git a/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/module_private.map b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/module_private.map
new file mode 100644
index 00000000000000..0b3b5a78b8741d
--- /dev/null
+++ b/clang/test/Modules/Inputs/ModuleMapLocations/Module_Map_F.framework/module_private.map
@@ -0,0 +1,3 @@
+explicit framework module Module_Map_F.Private {
+ header "private.h"
+}
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/module.map b/clang/test/Modules/Inputs/NoUmbrella.framework/Modules/module.modulemap
similarity index 100%
rename from clang/test/Modules/Inputs/NoUmbrella.framework/module.map
rename to clang/test/Modules/Inputs/NoUmbrella.framework/Modules/module.modulemap
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map b/clang/test/Modules/Inputs/NoUmbrella.framework/Modules/module.private.modulemap
similarity index 100%
rename from clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map
rename to clang/test/Modules/Inputs/NoUmbrella.framework/Modules/module.priv...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
The legacy `module.map` spelling of module map files was deprecated by llvm/llvm-project#75142 and clang expects to remove support for them in the future. Switch all tests to use the supported spelling. Fixes rdar://128431478.
This patch deprecates
module.mapin favor ofmodule.modulemap, which has been the preferred form since 2014. The eventual goal is to remove support formodule.mapto 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: