This is an archive of the discontinued LLVM Phabricator instance.

Add flag -f(no-)modules-implicit-maps.
ClosedPublic

Authored by djasper on Nov 18 2014, 5:40 AM.

Details

Reviewers
rsmith
Summary

This suppresses the implicit search for files called 'module.modulemap' and similar.

Diff Detail

Event Timeline

djasper updated this revision to Diff 16324.Nov 18 2014, 5:40 AM
djasper retitled this revision from to Add flag -fno-modules-implicit-maps..
djasper updated this object.
djasper edited the test plan for this revision. (Show Details)
djasper added a reviewer: rsmith.
djasper added subscribers: klimek, Unknown Object (MLST).
rsmith edited edge metadata.Nov 19 2014, 10:45 AM

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).
docs/Modules.rst
211

In the documentation, we should refer to module.modulemap rather than the deprecated name module.map.

include/clang/Basic/LangOptions.def
129

module.modulemap

129

This should be a COMPATIBLE_LANGOPT (or possibly a BENIGN_LANGOPT).

include/clang/Driver/Options.td
678–680

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).

I think HeaderSearch::loadFrameworkModule() should not call ModuleMap::inferFrameworkModule() if implicit maps are deactivated. Inferred maps seems like a special case of implicit maps.

Also addressed all the other points.

docs/Modules.rst
211

Changed.

include/clang/Basic/LangOptions.def
129

Made it a BENIGN_LANGOPT.

129

Done.

include/clang/Driver/Options.td
678–680

Done.

djasper updated this revision to Diff 16422.Nov 20 2014, 1:44 AM
djasper retitled this revision from Add flag -fno-modules-implicit-maps. to Add flag -f(no-)modules-implicit-maps..
djasper updated this object.
djasper edited edge metadata.
rsmith accepted this revision.Nov 24 2014, 10:37 AM
rsmith edited edge metadata.

One comment to address, then please go ahead and commit.

lib/Frontend/CompilerInvocation.cpp
1467

You're initializing this from itself if neither flag is set. Did you mean Opts.Modules or Opts.ModuleMaps, or maybe true?

This revision is now accepted and ready to land.Nov 24 2014, 10:37 AM
djasper closed this revision.Nov 25 2014, 1:46 AM

Fixed and submitted as r222745. Thanks!