[PATCH] D33703: Support lazy stat'ing of files referenced by module maps

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 17:00:31 PDT 2017


rsmith created this revision.

This patch adds support for a `header` declaration in a module map to specify certain `stat` information (currently, size and mtime) about that header file. This has two purposes:

- It removes the need to eagerly `stat` every file referenced by a module map. Instead, we track a list of unresolved header files with each size / mtime (actually, for simplicity, we track submodules with such headers), and when attempting to look up a header file based on a `FileEntry`, we check if there are any unresolved header directives with that `FileEntry`'s size / mtime and perform deferred `stat`s if so.

- It permits a preprocessed module to be compiled without the original files being present on disk. The only reason we used to need those files was to get the `stat` information in order to do header -> module lookups when using the module. If we're provided with the `stat` information in the preprocessed module, we can avoid requiring the files to exist.

Unlike most `header` directives, if a `header` directive with `stat` information has no corresponding on-disk file the enclosing module is *not* marked unavailable (so that behavior is consistent regardless of whether we've resolved a header directive, and so that preprocessed modules don't get marked unavailable). We could actually do this for all `header` directives: the only reason we mark the module unavailable if headers are missing is to give a diagnostic slightly earlier (rather than waiting until we actually try to build the module / load and validate its .pcm file).


Repository:
  rL LLVM

https://reviews.llvm.org/D33703

Files:
  docs/Modules.rst
  include/clang/Basic/DiagnosticIDs.h
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Basic/DiagnosticSerializationKinds.td
  include/clang/Basic/Module.h
  include/clang/Lex/ModuleMap.h
  lib/Basic/Module.cpp
  lib/Frontend/FrontendAction.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Lex/ModuleMap.cpp
  lib/Lex/PPDirectives.cpp
  lib/Serialization/ASTWriter.cpp
  test/Modules/Inputs/header-attribs/bar.h
  test/Modules/Inputs/header-attribs/baz.h
  test/Modules/Inputs/header-attribs/foo.h
  test/Modules/Inputs/header-attribs/modular.modulemap
  test/Modules/Inputs/header-attribs/textual.modulemap
  test/Modules/diagnostics.modulemap
  test/Modules/preprocess-module.cpp
  test/Modules/preprocess-nested.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33703.100799.patch
Type: text/x-patch
Size: 46463 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170531/c0b11ef6/attachment-0001.bin>


More information about the cfe-commits mailing list