Add support for building modules from preprocessed source.
To support this, an optional marker "#pragma clang module contents" is recognized in module map files, and the rest of the module map file from that point onwards is treated as the source of the module. Preprocessing a module map produces the input module followed by the marker and then the preprocessed contents of the module. Ignoring line markers, a preprocessed module might look like this: module A { header "a.h" } #pragma clang module contents #pragma clang module begin A // ... a.h ... #pragma clang module end The preprocessed output generates line markers, which are not accepted by the module map parser, so -x c++-module-map-cpp-output should be used to compile such outputs. A couple of major parts do not work yet: 1) The files that are listed in the module map must exist on disk, in order to build the on-disk header -> module lookup table in the PCM file. To fix this, we need the preprocessed output to track the file size and other stat information we might use to build the lookup table. 2) Declaration ownership semantics don't work properly yet, since mapping from a source location to a module relies on mapping from FileIDs to modules, which we can't do if module transitions can occur in the middle of a file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302309 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/Frontend/FrontendAction.h 2 additions, 0 deletionsinclude/clang/Frontend/FrontendAction.h
- include/clang/Lex/HeaderSearch.h 10 additions, 2 deletionsinclude/clang/Lex/HeaderSearch.h
- include/clang/Lex/ModuleMap.h 8 additions, 2 deletionsinclude/clang/Lex/ModuleMap.h
- lib/Frontend/FrontendAction.cpp 146 additions, 81 deletionslib/Frontend/FrontendAction.cpp
- lib/Frontend/FrontendActions.cpp 12 additions, 0 deletionslib/Frontend/FrontendActions.cpp
- lib/Frontend/Rewrite/FrontendActions.cpp 12 additions, 0 deletionslib/Frontend/Rewrite/FrontendActions.cpp
- lib/Lex/HeaderSearch.cpp 6 additions, 4 deletionslib/Lex/HeaderSearch.cpp
- lib/Lex/ModuleMap.cpp 49 additions, 9 deletionslib/Lex/ModuleMap.cpp
- lib/Sema/SemaDecl.cpp 13 additions, 6 deletionslib/Sema/SemaDecl.cpp
- test/Modules/preprocess-module.cpp 38 additions, 2 deletionstest/Modules/preprocess-module.cpp
Loading
Please register or sign in to comment