diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-06-02 01:55:39 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-06-02 01:55:39 +0000 |
commit | 040e12662a674e2ebfc93f86a70eddb7d6fc76da (patch) | |
tree | 584207a7572d85ef6f3fefca3395edfccc7e6e00 /clang/test/Modules/header-attribs.cpp | |
parent | ae80045debdd1c46bfa233c87247182862bf4437 (diff) | |
download | bcm5719-llvm-040e12662a674e2ebfc93f86a70eddb7d6fc76da.tar.gz bcm5719-llvm-040e12662a674e2ebfc93f86a70eddb7d6fc76da.zip |
Support lazy stat'ing of files referenced by module maps.
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).
Differential Revision: https://reviews.llvm.org/D33703
llvm-svn: 304515
Diffstat (limited to 'clang/test/Modules/header-attribs.cpp')
-rw-r--r-- | clang/test/Modules/header-attribs.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Modules/header-attribs.cpp b/clang/test/Modules/header-attribs.cpp new file mode 100644 index 00000000000..292a94561e4 --- /dev/null +++ b/clang/test/Modules/header-attribs.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -I%S/Inputs/header-attribs -fmodule-map-file=%S/Inputs/header-attribs/textual.modulemap -fmodules-cache-path=%t -verify %s -fmodule-name=A -fmodules-strict-decluse +// RUN: not %clang_cc1 -fmodules -I%S/Inputs/header-attribs -emit-module -x c++-module-map %S/Inputs/header-attribs/modular.modulemap -fmodules-cache-path=%t -fmodule-name=A 2>&1 | FileCheck %s --check-prefix BUILD-MODULAR + +#include "foo.h" // ok, stats match +#include "bar.h" // expected-error {{does not depend on a module exporting 'bar.h'}} +#include "baz.h" // expected-error {{does not depend on a module exporting 'baz.h'}} + +// FIXME: Explain why the 'bar.h' found on disk doesn't match the module map. +// BUILD-MODULAR: error: header 'bar.h' not found |