[modules] Add ability to specify module name to module file mapping
authorBoris Kolpackov <boris@codesynthesis.com>
Wed, 30 Aug 2017 08:45:59 +0000 (08:45 +0000)
committerBoris Kolpackov <boris@codesynthesis.com>
Wed, 30 Aug 2017 08:45:59 +0000 (08:45 +0000)
commit7a71b4b6584fd70f43b88049174f8894cab3a4d2
treef5b82d4b250eaeb6ee5d3838d470f1bf8a707271
parentbe5b60f735587104d1fe580bcabd1e011ac0c566
[modules] Add ability to specify module name to module file mapping

Extend the -fmodule-file option to support the [<name>=]<file> value format.
If the name is omitted, then the old semantics is preserved (the module file
is loaded whether needed or not). If the name is specified, then the mapping
is treated as just another prebuilt module search mechanism, similar to
-fprebuilt-module-path, and the module file is only loaded if actually used
(e.g., via import). With one exception: this mapping also overrides module
file references embedded in other modules (which can be useful if module files
are moved/renamed as often happens during remote compilation).

This override semantics requires some extra work: we now store the module name
in addition to the file name in the serialized AST representation.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D35020

llvm-svn: 312105
16 files changed:
clang/docs/Modules.rst
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/HeaderSearchOptions.h
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/Serialization/ModuleManager.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/GlobalModuleIndex.cpp
clang/lib/Serialization/ModuleManager.cpp
clang/test/CXX/modules-ts/basic/basic.search/module-import.cpp [new file with mode: 0644]