blob: e5ee62e33303419e58ffea55c2e895107d7a16d0 [file] [log] [blame]
John Thompson2d2d45e2013-09-20 14:40:52 +00001.. index:: modularize
2
3==================================
4Modularize User's Manual
5==================================
6
7.. toctree::
8 :hidden:
9
10 ModularizeUsage
11
12:program:`modularize` is a standalone tool that checks whether a set of headers
13provides the consistent definitions required to use modules. For example, it
14detects whether the same entity (say, a NULL macro or size_t typedef) is
15defined in multiple headers or whether a header produces different definitions
16under different circumstances. These conditions cause modules built from the
17headers to behave poorly, and should be fixed before introducing a module
18map.
19
20Getting Started
21===============
22
23To build from source:
24
251. Read `Getting Started with the LLVM System`_ and `Clang Tools
26 Documentation`_ for information on getting sources for LLVM, Clang, and
27 Clang Extra Tools.
28
292. `Getting Started with the LLVM System`_ and `Building LLVM with CMake`_ give
30 directions for how to build. With sources all checked out into the
31 right place the LLVM build will build Clang Extra Tools and their
32 dependencies automatically.
33
34 * If using CMake, you can also use the ``modularize`` target to build
35 just the modularize tool and its dependencies.
36
37Before continuing, take a look at :doc:`ModularizeUsage` to see how to invoke
38modularize.
39
40.. _Getting Started with the LLVM System: http://llvm.org/docs/GettingStarted.html
41.. _Building LLVM with CMake: http://llvm.org/docs/CMake.html
42.. _Clang Tools Documentation: http://clang.llvm.org/docs/ClangTools.html
43
44What Modularize Checks
45======================
46
47Modularize will do normal C/C++ parsing, reporting normal errors and warnings,
48but will also report special error messages like the following:
49
50 | error: '(symbol)' defined at multiple locations:
51 | (file):(row):(column)
52 | (file):(row):(column)
53
54 error: header '(file)' has different contents depending on how it was
55 included
56
57The latter might be followed by messages like the following:
58
59 | note: '(symbol)' in (file) at (row):(column) not always provided
60
61Checks will also be performed for macro expansions, defined(macro)
62expressions, and preprocessor conditional directives that evaluate
63inconsistently, and can produce error messages like the following:
64
65 | (...)/SubHeader.h:11:5:
66 | #if SYMBOL == 1
67 | ^
68 | error: Macro instance 'SYMBOL' has different values in this header,
69 | depending on how it was included.
70 | 'SYMBOL' expanded to: '1' with respect to these inclusion paths:
71 | (...)/Header1.h
72 | (...)/SubHeader.h
73 | (...)/SubHeader.h:3:9:
74 | #define SYMBOL 1
75 | ^
76 | Macro defined here.
77 | 'SYMBOL' expanded to: '2' with respect to these inclusion paths:
78 | (...)/Header2.h
79 | (...)/SubHeader.h
80 | (...)/SubHeader.h:7:9:
81 | #define SYMBOL 2
82 | ^
83 | Macro defined here.
84
85Checks will also be performed for '#include' directives that are
86nested inside 'extern "C/C++" {}' or 'namespace (name) {}' blocks,
87and can produce error message like the following:
88
89 | IncludeInExtern.h:2:3:
90 | #include "Empty.h"
91 | ^
92 | error: Include directive within extern "C" {}.
93 | IncludeInExtern.h:1:1:
94 | extern "C" {
95 | ^
96 | The "extern "C" {}" block is here.