[PATCH] D141450: [Clang][cc1] Add -fno-modules-local-submodule-visibility to override the default
Michael Spencer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 10 17:19:36 PST 2023
Bigcheese created this revision.
Bigcheese added reviewers: jansvoboda11, dblaikie, iains, ChuanqiXu.
Bigcheese added projects: clang-modules, clang.
Herald added a subscriber: ributzka.
Herald added a project: All.
Bigcheese requested review of this revision.
Currently there is no way to have Objective-C++20 without LSV. This is
a problem because some existing ObjectiveC code is not compatible with
LSV. This patch provides a way to disable LSV even in C++20 mode.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141450
Files:
clang/include/clang/Driver/Options.td
clang/test/Modules/fno-modules-local-submodule-visibility.mm
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 -fno-modules-local-submodule-visibility
+// 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
+
+//--- 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/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5918,12 +5918,13 @@
"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)>,
+ 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.488042.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230111/2f9a1a73/attachment.bin>
More information about the cfe-commits
mailing list