summaryrefslogtreecommitdiff
path: root/docs/Modules.rst
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-09-24 09:14:14 +0000
committerDaniel Jasper <djasper@google.com>2013-09-24 09:14:14 +0000
commitddd2dfc1d3f4a36cbe8cd775c588623a17049f9f (patch)
tree99fe31428c47f0d77c5cf9cc45c6ab33fdbaaeab /docs/Modules.rst
parentfc12c4aa20876bdf91bff98dc50eb68b4dd04b80 (diff)
downloadclang-ddd2dfc1d3f4a36cbe8cd775c588623a17049f9f.tar.gz
clang-ddd2dfc1d3f4a36cbe8cd775c588623a17049f9f.tar.bz2
clang-ddd2dfc1d3f4a36cbe8cd775c588623a17049f9f.tar.xz
Module use declarations (II)
Review: http://llvm-reviews.chandlerc.com/D1546. I have picked up this patch form Lawrence (http://llvm-reviews.chandlerc.com/D1063) and did a few changes. From the original change description (updated as appropriate): This patch adds a check that ensures that modules only use modules they have so declared. To this end, it adds a statement on intended module use to the module.map grammar: use module-id A module can then only use headers from other modules if it 'uses' them. This enforcement is off by default, but may be turned on with the new option -fmodules-decluse. When enforcing the module semantics, we also need to consider a source file part of a module. This is achieved with a compiler option -fmodule-name=<module-id>. The compiler at present only applies restrictions to the module directly being built. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191283 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/Modules.rst')
-rw-r--r--docs/Modules.rst39
1 files changed, 38 insertions, 1 deletions
diff --git a/docs/Modules.rst b/docs/Modules.rst
index 8c20301315..02393d7ba9 100644
--- a/docs/Modules.rst
+++ b/docs/Modules.rst
@@ -188,6 +188,12 @@ Command-line parameters
``-module-file-info <module file name>``
Debugging aid that prints information about a given module file (with a ``.pcm`` extension), including the language and preprocessor options that particular module variant was built with.
+``-fmodules-decluse``
+ Enable checking of module ``use`` declarations.
+
+``-fmodule-name=module-id``
+ Consider a source file as a part of the given module.
+
Module Map Language
===================
@@ -238,7 +244,7 @@ Module map files use a simplified form of the C99 lexer, with the same rules for
``conflict`` ``framework`` ``requires``
``exclude`` ``header`` ``private``
``explicit`` ``link`` ``umbrella``
- ``extern``
+ ``extern`` ``use``
Module map file
---------------
@@ -293,6 +299,7 @@ Modules can have a number of different kinds of members, each of which is descri
*umbrella-dir-declaration*
*submodule-declaration*
*export-declaration*
+ *use-declaration*
*link-declaration*
*config-macros-declaration*
*conflict-declaration*
@@ -533,6 +540,36 @@ Note that, if ``Derived.h`` includes ``Base.h``, one can simply use a wildcard e
compatibility for programs that rely on transitive inclusion (i.e.,
all of them).
+Use declaration
+~~~~~~~~~~~~~~~
+A *use-declaration* specifies one of the other modules that the module is allowed to use. An import or include not matching one of these is rejected when the option *-fmodules-decluse*.
+
+.. parsed-literal::
+
+ *use-declaration*:
+ ``use`` *module-id*
+
+**Example**:: In the following example, use of A from C is not declared, so will trigger a warning.
+
+.. parsed-literal::
+
+ module A {
+ header "a.h"
+ }
+
+ module B {
+ header "b.h"
+ }
+
+ module C {
+ header "c.h"
+ use B
+ }
+
+When compiling a source file that implements a module, use the option ``-fmodule-name=``module-id to indicate that the source file is logically part of that module.
+
+The compiler at present only applies restrictions to the module directly being built.
+
Link declaration
~~~~~~~~~~~~~~~~
A *link-declaration* specifies a library or framework against which a program should be linked if the enclosing module is imported in any translation unit in that program.