[PATCH] Add flag -fno-modules-implicit-maps.
Richard Smith
richard at metafoo.co.uk
Wed Nov 19 10:45:53 PST 2014
I'm not sure this will do the right thing for framework modules; it looks like we'll infer a module map if you disable implicit module maps for them, which doesn't seem like the right behavior (see `HeaderSearch::loadFrameworkModule`).
There are a bunch of other functions in this file which do redundant work that we should short-circuit in this case:
* `HeaderSearch::lookupModule` should bail out after checking to see if we've already loaded the module, rather than looping over the include paths and doing nothing with them.
* `HeaderSearch::hasModuleMap` should just return immediately, rather than scanning upwards over all parent directories of a file and doing nothing with them.
* `HeaderSearch::collectAllModules` should skip its loop over all include paths.
* `HeaderSearch::loadTopLevelSystemModules` should skip its loop over all include paths.
* `HeaderSearch::loadSubdirectoryModuleMaps` should bail out or assert (it shouldn't be reachable if implicit module maps are disabled).
================
Comment at: docs/Modules.rst:211
@@ +210,3 @@
+``-fno-modules-implicit-maps``
+ Suppresses the implicit search for files called ``module.map`` and similar. Instead, module files need to be explicitly specified via ``-fmodule-map-file`` or transitively used.
+
----------------
In the documentation, we should refer to `module.modulemap` rather than the deprecated name `module.map`.
================
Comment at: include/clang/Basic/LangOptions.def:129
@@ -128,2 +128,3 @@
LANGOPT(ModulesErrorRecovery, 1, 1, "automatically import modules as needed when performing error recovery")
+LANGOPT(ModulesImplicitMaps, 1, 1, "use files called module.map implicitly as module maps")
COMPATIBLE_LANGOPT(Optimize , 1, 0, "__OPTIMIZE__ predefined macro")
----------------
`module.modulemap`
================
Comment at: include/clang/Basic/LangOptions.def:129
@@ -128,2 +128,3 @@
LANGOPT(ModulesErrorRecovery, 1, 1, "automatically import modules as needed when performing error recovery")
+LANGOPT(ModulesImplicitMaps, 1, 1, "use files called module.map implicitly as module maps")
COMPATIBLE_LANGOPT(Optimize , 1, 0, "__OPTIMIZE__ predefined macro")
----------------
rsmith wrote:
> `module.modulemap`
This should be a `COMPATIBLE_LANGOPT` (or possibly a `BENIGN_LANGOPT`).
================
Comment at: include/clang/Driver/Options.td:678-680
@@ -677,2 +677,5 @@
Flags<[DriverOption, CC1Option]>;
+def fno_modules_implicit_maps :
+ Flag <["-"], "fno-modules-implicit-maps">,
+ Group<f_Group>, Flags<[DriverOption, CC1Option]>;
def fretain_comments_from_system_headers : Flag<["-"], "fretain-comments-from-system-headers">, Group<f_Group>, Flags<[CC1Option]>;
----------------
For driver options, we typically include both a `-fblah` and a `-fno-blah` (so the user can override earlier command-line options from `$CXXFLAGS` or similar).
http://reviews.llvm.org/D6305
More information about the cfe-commits
mailing list