[clang] 4069dd1 - [modules] Allow frameworks to have only a private module without a public one.
Volodymyr Sapsai via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 28 15:41:36 PST 2020
Author: Volodymyr Sapsai
Date: 2020-02-28T15:40:24-08:00
New Revision: 4069dd14124e9a84b46f48153d4fbc4da811a45e
URL: https://github.com/llvm/llvm-project/commit/4069dd14124e9a84b46f48153d4fbc4da811a45e
DIFF: https://github.com/llvm/llvm-project/commit/4069dd14124e9a84b46f48153d4fbc4da811a45e.diff
LOG: [modules] Allow frameworks to have only a private module without a public one.
Support only preferred spelling 'Modules/module.private.modulemap' and
not the deprecated 'module_private.map'.
rdar://problem/57715533
Reviewed By: bruno
Differential Revision: https://reviews.llvm.org/D75311
Added:
clang/test/Modules/Inputs/implicit-private-without-public/DeprecatedModuleMapLocation.framework/PrivateHeaders/A.h
clang/test/Modules/Inputs/implicit-private-without-public/DeprecatedModuleMapLocation.framework/module_private.map
clang/test/Modules/Inputs/implicit-private-without-public/Foo.framework/Modules/module.private.modulemap
clang/test/Modules/Inputs/implicit-private-without-public/Foo.framework/PrivateHeaders/Foo_Priv.h
clang/test/Modules/implicit-private-without-public.m
Modified:
clang/lib/Lex/HeaderSearch.cpp
Removed:
################################################################################
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 65d109ebf034..1199f75f8a3c 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1568,6 +1568,16 @@ HeaderSearch::lookupModuleMapFile(const DirectoryEntry *Dir, bool IsFramework) {
llvm::sys::path::append(ModuleMapFileName, "module.map");
if (auto F = FileMgr.getFile(ModuleMapFileName))
return *F;
+
+ // For frameworks, allow to have a private module map with a preferred
+ // spelling when a public module map is absent.
+ if (IsFramework) {
+ ModuleMapFileName = Dir->getName();
+ llvm::sys::path::append(ModuleMapFileName, "Modules",
+ "module.private.modulemap");
+ if (auto F = FileMgr.getFile(ModuleMapFileName))
+ return *F;
+ }
return nullptr;
}
diff --git a/clang/test/Modules/Inputs/implicit-private-without-public/DeprecatedModuleMapLocation.framework/PrivateHeaders/A.h b/clang/test/Modules/Inputs/implicit-private-without-public/DeprecatedModuleMapLocation.framework/PrivateHeaders/A.h
new file mode 100644
index 000000000000..8ed2304c36b9
--- /dev/null
+++ b/clang/test/Modules/Inputs/implicit-private-without-public/DeprecatedModuleMapLocation.framework/PrivateHeaders/A.h
@@ -0,0 +1 @@
+void a(void);
diff --git a/clang/test/Modules/Inputs/implicit-private-without-public/DeprecatedModuleMapLocation.framework/module_private.map b/clang/test/Modules/Inputs/implicit-private-without-public/DeprecatedModuleMapLocation.framework/module_private.map
new file mode 100644
index 000000000000..1b44bb577491
--- /dev/null
+++ b/clang/test/Modules/Inputs/implicit-private-without-public/DeprecatedModuleMapLocation.framework/module_private.map
@@ -0,0 +1,4 @@
+framework module DeprecatedModuleMapLocation_Private {
+ header "A.h"
+ export *
+}
diff --git a/clang/test/Modules/Inputs/implicit-private-without-public/Foo.framework/Modules/module.private.modulemap b/clang/test/Modules/Inputs/implicit-private-without-public/Foo.framework/Modules/module.private.modulemap
new file mode 100644
index 000000000000..fa1057cab79c
--- /dev/null
+++ b/clang/test/Modules/Inputs/implicit-private-without-public/Foo.framework/Modules/module.private.modulemap
@@ -0,0 +1,4 @@
+framework module Foo_Private {
+ header "Foo_Priv.h"
+ export *
+}
diff --git a/clang/test/Modules/Inputs/implicit-private-without-public/Foo.framework/PrivateHeaders/Foo_Priv.h b/clang/test/Modules/Inputs/implicit-private-without-public/Foo.framework/PrivateHeaders/Foo_Priv.h
new file mode 100644
index 000000000000..2899e07cc6bb
--- /dev/null
+++ b/clang/test/Modules/Inputs/implicit-private-without-public/Foo.framework/PrivateHeaders/Foo_Priv.h
@@ -0,0 +1 @@
+void foo_private(void);
diff --git a/clang/test/Modules/implicit-private-without-public.m b/clang/test/Modules/implicit-private-without-public.m
new file mode 100644
index 000000000000..e4920bcc7ec6
--- /dev/null
+++ b/clang/test/Modules/implicit-private-without-public.m
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN: -F%S/Inputs/implicit-private-without-public \
+// RUN: -fsyntax-only %s -verify
+
+ at import Foo_Private;
+
+// Private module map without a public one isn't supported for deprecated module map locations.
+ at import DeprecatedModuleMapLocation_Private;
+// expected-error at -1{{module 'DeprecatedModuleMapLocation_Private' not found}}
More information about the cfe-commits
mailing list