[PATCH] D141450: [Clang][cc1] Make -fno-modules-local-submodule-visibility the default for ObjC++20
Michael Spencer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 17 16:08:37 PST 2023
Bigcheese updated this revision to Diff 489970.
Bigcheese retitled this revision from "[Clang][cc1] Add -fno-modules-local-submodule-visibility to override the default" to "[Clang][cc1] Make -fno-modules-local-submodule-visibility the default for ObjC++20".
Bigcheese edited the summary of this revision.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141450/new/
https://reviews.llvm.org/D141450
Files:
clang/include/clang/Driver/Options.td
clang/test/Modules/cxx20-disable.cpp
clang/test/Modules/fno-modules-local-submodule-visibility.mm
clang/test/Modules/import-syntax.c
Index: clang/test/Modules/import-syntax.c
===================================================================
--- clang/test/Modules/import-syntax.c
+++ clang/test/Modules/import-syntax.c
@@ -8,7 +8,7 @@
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x objective-c++ -DAT_IMPORT=1 %s
//
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x c++ -fmodules-ts -DIMPORT=1 %s
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x objective-c++ -fmodules-ts -DIMPORT=1 %s
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -fmodules-local-submodule-visibility -verify -x objective-c++ -fmodules-ts -DIMPORT=1 %s
//
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x c -DPRAGMA %s
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x objective-c -DPRAGMA %s
Index: clang/test/Modules/fno-modules-local-submodule-visibility.mm
===================================================================
--- /dev/null
+++ clang/test/Modules/fno-modules-local-submodule-visibility.mm
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -std=c++20 -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t -fsyntax-only -I %t/include -x objective-c++ \
+// RUN: %t/tu.m -verify
+// RUN: %clang_cc1 -std=c++20 -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t -fsyntax-only -I %t/include -x objective-c++ \
+// RUN: %t/tu2.m -verify -fmodules-local-submodule-visibility
+
+//--- include/module.modulemap
+
+module M {
+ module A {
+ header "A.h"
+ export *
+ }
+ module B {
+ header "B.h"
+ export *
+ }
+}
+
+//--- include/A.h
+#define A 1
+
+//--- include/B.h
+inline int B = A;
+
+//--- tu.m
+ at import M;
+int i = B;
+// expected-no-diagnostics
+
+//--- tu2.m
+ at import M; // expected-error {{could not build module 'M'}}
Index: clang/test/Modules/cxx20-disable.cpp
===================================================================
--- clang/test/Modules/cxx20-disable.cpp
+++ clang/test/Modules/cxx20-disable.cpp
@@ -1,5 +1,5 @@
// RUN: rm -rf %t && mkdir %t
-// RUN: %clang_cc1 -x objective-c++ -std=c++20 -I %t %s -verify=enabled
+// RUN: %clang_cc1 -x objective-c++ -std=c++20 -I %t %s -verify=enabled -fmodules-local-submodule-visibility
// RUN: %clang_cc1 -x objective-c++ -std=c++20 -fno-cxx-modules -I %t %s -verify=disabled
// enabled-no-diagnostics
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5918,12 +5918,14 @@
"duplicating work in competing clang invocations.">>;
// FIXME: We only need this in C++ modules / Modules TS if we might textually
// enter a different module (eg, when building a header unit).
-def fmodules_local_submodule_visibility :
- Flag<["-"], "fmodules-local-submodule-visibility">,
- HelpText<"Enforce name visibility rules across submodules of the same "
- "top-level module.">,
- MarshallingInfoFlag<LangOpts<"ModulesLocalVisibility">>,
- ImpliedByAnyOf<[fmodules_ts.KeyPath, fcxx_modules.KeyPath]>;
+defm modules_local_submodule_visibility :
+ BoolFOption<"modules-local-submodule-visibility",
+ LangOpts<"ModulesLocalVisibility">,
+ Default<!strconcat("(", fmodules_ts.KeyPath, "||", fcxx_modules.KeyPath,
+ ") && !LangOpts->ObjC")>,
+ PosFlag<SetTrue, [], "name visibility rules across submodules of the same "
+ "top-level module">,
+ NegFlag<SetFalse>>;
def fmodules_codegen :
Flag<["-"], "fmodules-codegen">,
HelpText<"Generate code for uses of this module that assumes an explicit "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141450.489970.patch
Type: text/x-patch
Size: 3959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230118/e8866916/attachment.bin>
More information about the cfe-commits
mailing list