]> granicus.if.org Git - clang/commit
Add support for building modules from preprocessed source.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 5 May 2017 22:18:51 +0000 (22:18 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 5 May 2017 22:18:51 +0000 (22:18 +0000)
commitbc4ab6d64d9314f4391752e17068eea2b9377e53
treeaa8750b7be9af01ca8ca90a8635f19390c75093d
parent7eaea28742ad4cb69d69e28d017bcb66005ba421
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
include/clang/Frontend/FrontendAction.h
include/clang/Lex/HeaderSearch.h
include/clang/Lex/ModuleMap.h
lib/Frontend/FrontendAction.cpp
lib/Frontend/FrontendActions.cpp
lib/Frontend/Rewrite/FrontendActions.cpp
lib/Lex/HeaderSearch.cpp
lib/Lex/ModuleMap.cpp
lib/Sema/SemaDecl.cpp
test/Modules/preprocess-module.cpp