John Thompson | 2d2d45e | 2013-09-20 14:40:52 +0000 | [diff] [blame^] | 1 | .. index:: modularize |
| 2 | |
| 3 | ================================== |
| 4 | Modularize 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 |
| 13 | provides the consistent definitions required to use modules. For example, it |
| 14 | detects whether the same entity (say, a NULL macro or size_t typedef) is |
| 15 | defined in multiple headers or whether a header produces different definitions |
| 16 | under different circumstances. These conditions cause modules built from the |
| 17 | headers to behave poorly, and should be fixed before introducing a module |
| 18 | map. |
| 19 | |
| 20 | Getting Started |
| 21 | =============== |
| 22 | |
| 23 | To build from source: |
| 24 | |
| 25 | 1. 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 | |
| 29 | 2. `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 | |
| 37 | Before continuing, take a look at :doc:`ModularizeUsage` to see how to invoke |
| 38 | modularize. |
| 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 | |
| 44 | What Modularize Checks |
| 45 | ====================== |
| 46 | |
| 47 | Modularize will do normal C/C++ parsing, reporting normal errors and warnings, |
| 48 | but 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 | |
| 57 | The latter might be followed by messages like the following: |
| 58 | |
| 59 | | note: '(symbol)' in (file) at (row):(column) not always provided |
| 60 | |
| 61 | Checks will also be performed for macro expansions, defined(macro) |
| 62 | expressions, and preprocessor conditional directives that evaluate |
| 63 | inconsistently, 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 | |
| 85 | Checks will also be performed for '#include' directives that are |
| 86 | nested inside 'extern "C/C++" {}' or 'namespace (name) {}' blocks, |
| 87 | and 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. |